网站首页 文章专栏 MYSQL查询~ 存在一个表而不在另一个表中的数据
1.
select * from B where (select count(1) as num from A where A.id = B.uid) = 0 //查询速度最快
2.
select A.id from A left join B on A.id=B.uid where B.uid is null //左连接查找,查询速度稍慢与上一条
3.
select distinct A.id from A where A.id not in (select uid from B) //not in 简单粗暴,但是属于慢查询,数据量很大不建议使用
转载请注明出处