メモ:not in と not exists は等価じゃない

どっかで書いた気もするけど、null が混じったときに結果が違うよと。

select * from (values (1), (2), (3)) as a(id)
where a.id not in (select * from (values (null), (2)) as b(id))

結果無し

select * from (values (1), (2), (3)) as a(id)
where not exists (select * from (values (null), (2)) as b(id) where b.id = a.id)

1、3 がヒット。

f:id:odashinsuke:20220107085503p:plain