このクエリを書き換えて、左の結合で 'not in'を削除しようとしていますが、自分自身を混乱させてしまいました。 (驚きませんなし)'not in'の代わりにSQLを使用する
オリジナルクエリ:
select parentfolderid from folderrelationships with (nolock)
where childfolderid = 14908
and parentfolderid not in (select folderid from folders with (nolock) where typeid in (153,155))
私の新しいバージョン:
select parentfolderid from folderrelationships fr with (nolock)
LEFT JOIN folders f on f.FolderId = fr.ParentFolderID
where childfolderid = 14908 AND f.TypeID in (153,155)
が、私はすべての結果を取得しておりませんので..私はちょうどそれを取得しておりません。
私はこの問題は、 'TypeId in(153,155)in'をすべて考慮していると思います。それはどこに置くのか分かりません。
軽度の迂回路... http://blogs.sqlsentry.com/aaronbertrand/bad-habits-nolock-everywhere/ –