您的位置:首页 > 其它

怎么查询在A表中不存在的B表的数据(id+bm两个条件)

2017-11-24 09:20 369 查看
如何查询在A表中不存在的B表的数据(id+bm两个条件)

A 表

id bm

1 2

1 3

1 4

b表

id bm

1 2

1 3

1 4

1 5

1 6

如何查询在A表中不存在的B表的数据(id+bm两个条件)

如图的话就是

1 5

1 6

------解决方案--------------------

SQL code
select b.*
from b
where not exists(select 1 from a where a.id=b.id and a.bm=b.bm)

------解决方案--------------------
SQL code
select * from a where not exists(select 1 from tb where id=a.id and bm=a.bm)

------解决方案--------------------
SQL code
select * from b except select * from a

------解决方案--------------------
select *  from A where checksum(id, bm) not in (select checksum(id, bm)from B)

------解决方案--------------------
SQL code
select * from B
WHERE NOT EXISTS (SELECT 1 FROM A WHERE id = B.id AND bm = B.bm)

------解决方案--------------------
SQL code
select * from a where checksum(*) not in(select checksum(*) from b)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐