首页 > 应用开发 > IT综合 > in和exists的一些区别
注意: 下面这种情况从vcard表里返回的数据多,这时用exists效率高
select *
from day_onlinenum o where not exists (select username from vcard v where v.username = o.username);
下面day_onlinenum返回的数据少,所以用in效率高
select count(*)
from vcard where username in (select username from day_onlinenum)
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7916042/viewspace-919004/ ,如需转载,请注明出处,否则将追究法律责任。