两种执行的效果一样,但执行的速度不一样,在大数据的时候,可看出。
select distinct(a.o_flowid) from chengjiinfo as a where k_kecheng not in(select kemu from chengjidankeinfo where o_flowid=a.o_flowid)
//这个是要循环全表。查询数据。执行效率低。
select * from chengjiinfo as a where not exists(select 1 from chengjidankeinfo as b where a.o_flowid=b.o_flowid and a.k_kecheng=b.kemu)
这个是循环满足条件的数据,查询数据。执行效率高。

被折叠的 条评论
为什么被折叠?



