Posts Tagged ‘not in’

NULLs vs. NOT IN()

2008-08-13 10:58:59 CEST | 19 Comments | Tags: , ,

Friend of mine found something that he thought looked like a bug in Pg.

Very simple query:

select * from table where id not in (select field from other_table)

was not returning any rows, despite the fact that there definitely are some “ids” that are not in other_table.field. Why is that?

- MORE -