1. join 有 left join,right join,inner join 這三種,對兩個表作了笛卡爾積,而後再對結果集進行選取操做,選取知足條件的部分爲結果。web
2.in 是做爲一個條件查詢來使用的:sql
select * from Persons where lastName in ('Adams', 'Carter')數據庫
兩個語句的差異,能夠使用sql優化器看看它們執行的效率:優化
select count(distinct(typ.orig_id)) from sch.NWSTYP typ left outer join sch.NWSATT att on typ.orig_id = att.Orig_id where att.fld_code = '4' and att.fld_val = '1101';
select count(distinct(typ.orig_id)) from sch.NWSTYP typ,sch.NWSATT att where typ.TYP_CODE = '1501' and typ.orig_id = att.Orig_id and att.fld_code = '4' and att.fld_val = '1101';
code
上面第二條Sql 是默認使用了 inner join 來使用的。blog
網上查的還有提到exist ast
找了一篇文章:效率
http://weblogs.sqlteam.com/mladenp/archive/2007/05/18/60210.aspxselect
能夠看看。數據