IN EXISTS
--not in 和not exists 如果查询语句使用了not in 那么内外表都进行全表扫描,没有用到索引;而not extsts 的子查询依然能用到表上的索引。所以无论那个表大,用not exists都比not in要快。
--NOT IN
select * from OrderAsst A where A.OrgGid NOT IN( select A.OrgGid from Org B WHERE A.OrgGid=B.Gid ) AND A.Status='正常'
--NOT EXISTS
select * from OrderAsst A where NOT EXISTS(select A.OrgGid from Org B WHERE A.OrgGid=B.Gid) AND A.Status='正常'
--
-- IN
select * from OrderAsst A where A.OrgGid IN( select A.OrgGid from Org B WHERE A.OrgGid=B.Gid ) AND A.Status='正常'
--EXISTS
select * from OrderAsst A where EXISTS(select A.OrgGid from Org B WHERE A.OrgGid=B.Gid) AND A.Status='正常'