Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
1,用EXISTS替代IN、用NOT EXISTS替代NOT IN;
in的逻辑和 or是相同的,查询时必须找到所有符合的记录。
但exists则不同,他是存在的逻辑,也就是找到有一个就可以了
SELECT * FROM bdOrder
WHERE customid in ( select id form bmdCustomer ) //子查询会检查每一条记录
SELECT * FROM bdOrder a
WHERE EXISTS
( SELECT 1 FROM bmdCustomer b WHERE b.id = a.customerid ) //检查到存在的记录就返回