sql查询效率

来源:互联网 发布:淘宝店铺退货率高 编辑:程序博客网 时间:2024/05/20 02:29

需求:查出A表不在B表中的数据


方法1

select distinct A.ID from  A where A.ID not in (select ID from B)


方法2

select A.ID from A left join B on A.ID=B.ID where B.ID is null


方法3 

select * from  B  2     where (select count(1) as num from A where A.ID = B.ID) = 0

此效率最高


0 0