sql中的null值判断

null值不能用=, <>, in, not in作判断,只能使用IS NULL, IS NOT NULL

zlytest=# select 'true' where 3 in (1, 2, 3, null);
 ?column? 
----------
 true
(1 row)

zlytest=# select 'true' where 3 not in (1, 2, null);
 ?column? 
----------
(0 rows)

zlytest=# select 'true' where 3 = null;
 ?column? 
----------
(0 rows)

zlytest=# select 'true' where 3 <> null;
 ?column? 
----------
(0 rows)

zlytest=# select 'true' where 3 IS NULL;
 ?column? 
----------
(0 rows)

zlytest=# select 'true' where 3 IS NOT NULL;
 ?column? 
----------
 true
(1 row)