34,593
社区成员
发帖
与我相关
我的任务
分享
列出A表中不在B表中的记录
select * from LoverA a where not exists(select 1 from LoverB where id=a.id and phone=a.phone
and time=a.time and is_valid=a.is_valid)
列出A表中不在B表中的记录的总数:
select count(1) from LoverA a where not exists(select 1 from LoverB where id=a.id and phone=a.phone and time=a.time and is_valid=a.is_valid)
列出B表中不在A表中的记录:
select * from LoverB a where not exists(select 1 from LoverA where id=a.id and phone=a.phone
and time=a.time and is_valid=a.is_valid)
列出B表中不在A表中的记录的总数:
select count(1) from LoverB a where not exists(select 1 from LoverA where id=a.id and phone=a.phone and time=a.time and is_valid=a.is_valid)
--不知道你到底需要哪个?
select a.* from lovera a where phone not in (select phone from loverb)
select b.* from loverb b where phone not in (select phone from lovera)
select count(*) from lovera a where phone not in (select phone from loverb)
select count(*) from loverb b where phone not in (select phone from lovera)
select m.cnt + n.cnt from
(select cnt = count(*) from lovera a where phone not in (select phone from loverb)) m,
(select cnt = count(*) from loverb b where phone not in (select phone from lovera)) n