网上很多人在讨论In和Exists的性能对比,本人也搞不懂哪个性能更佳,只是一般在小表中用In,而在大表中用Exists。下面只是举例如果使用,以勉被喷了。1、In。1 select * from table1 a2 where a.Id in (select Id from table2)3 4 select * from table1 a5 where a.Id not in (select Id from table2)2、Exists。 1 select * from QVS_CUSTPACKINGSLIPPRINTJOUR a 2 where exists 3 (select PR. Read More
posted @ 2012-09-03 09:29 Sprite.z Views(291) Comments(0) Diggs(0) Edit
1、内联接(inner join)。内联接,显示连接表都有的记录,并按最多记录子表显示最终结果。1 select * from table1 a2 inner join table2 b on a.Id = b.Id3 where a.field...2、外联接(outer join)。外联接,又分为左联接(left join)和右联接(right join),显示主表所有记录,而子没有相关记录部分返回‘NULL’。outer join默认为左联接。1 select * from table1 a2 left join table2 b on a.Id = b.Id --显示table1的.. Read More
posted @ 2012-09-03 09:23 Sprite.z Views(173) Comments(0) Diggs(0) Edit