比如:table1
fieldA fieldB
-----------------------------
aaa bbb
bbb cc
ccc etable2
fieldA fieldB
-----------------------------
aaa bbb
bbb cc
table1与table2都是fieldA为主键
目标要检索出table2里对比table1少哪些记录。
无视fieldB的内容,如何最快速的检索出ccc这条记录?
fieldA fieldB
-----------------------------
aaa bbb
bbb cc
ccc etable2
fieldA fieldB
-----------------------------
aaa bbb
bbb cc
table1与table2都是fieldA为主键
目标要检索出table2里对比table1少哪些记录。
无视fieldB的内容,如何最快速的检索出ccc这条记录?
from table1 left join table2 using(fieldA)
where table2.fieldA is null
from table1 left join table2 on table1.fieldA = table1.fieldA
where table2.fieldA is null比较其它的方法 IN,EXISTS 速度略快一些。
where table2.fieldA is null