Home > Software engineering >  Postgresql Can't find any entries with `uniqueId NOT IN (null)`
Postgresql Can't find any entries with `uniqueId NOT IN (null)`

Time:04-26

I was wondering why in Postgresql (and maybe other sql-dialets) the following Query leads to no entries (my_table has entires and uniqueid is a PK):

SELECT uniqueid FROM my_table where uniqueid not in (null)

CodePudding user response:

Since the IN (...) clause has only one item in it, namely NULL, your query is identical to this:

SELECT uniqueid FROM my_table WHERE uniqueid != NULL;

Comparing any column/value against NULL is unknown and will never be true, and hence will never return any records.

  • Related