2014年2月15日土曜日

【SQLSERVER】 In句をExists句に置き換える

一般的にExists句のが高速、そのうえカスタマイズ性が高いのでおすすめ。
下記は簡単例です。1テーブルなのであまり意味はないですが。

◆In句
select *
   from xxx
 where col in ('a' ,'b')

◆Exists句
select *
   from xxx
 where Exists (
                        select 1
                           from xxx
                         where col in ('a' ,'b')
                       )

0 件のコメント:

コメントを投稿