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);