For example, ()
works in sqllite3
:
select *
from orders
where custid = ?
and status in ()
But it fails in postgres
:
ksysdb=# select code, applicable_objecttype
from pssystem_ktagtype where applicable_objecttype in ();
ERROR: syntax error at or near ")"
LINE 1: ...pe from pssystem_ktagtype where applicable_objecttype in ();
Using (null)
makes postgres happy, and doesn't seem to bother sqllite3:
ksysdb=# select code, applicable_objecttype
from pssystem_ktagtype where applicable_objecttype in (null);
code | applicable_objecttype
------+-----------------------
(0 rows)
But would it work on SQL Server and Oracle? What does ANSI SQL have to say? My guess is that null
will never match anything (including null
itself), so it the in list condition will always evaluate to false.