Java,J2EE,Weblogic,Oracle

java项目随笔
随笔 - 90, 文章 - 6, 评论 - 61, 引用 - 0
数据加载中……

oracle 查出2张表不同的记录(即A表有,B表却没有)

oracle 查出2张表不同的记录(即A表有,B表却没有)

原型:  select *  from t_user1  a    where not exists   (select  *  from  t_user2  b where a.id=b.id );

例子:
select *
  from (select *
          from tb_user_add_serv_fee_20100826 t
         where t.register_id in
               (select register_id
                  from tb_product_state_rent
                 where RENT_MONTH = '201007'
                   and REGISTER_ID in
                       (select register_id
                          from view_tb_product_state t
                         where reg_region_no in ('ST', 'SW')))
           and t.is_invalid = '1') tt1

 where not exists

 (select *
          from (select *
                  from tb_user_add_serv_fee t
                 where t.register_id in
                       (select register_id
                          from tb_product_state_rent
                         where RENT_MONTH = '201007'
                           and REGISTER_ID in
                               (select register_id
                                  from view_tb_product_state t
                                 where reg_region_no in ('ST', 'SW')))
                   and t.is_invalid = '1') tt2
       
         where tt1.register_id = tt2.register_id);


posted on 2010-09-14 22:41 龚椿深 阅读(1637) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: