IN Clause with NULL or IS NULL

后端 未结 7 1569
我在风中等你
我在风中等你 2020-11-30 00:26

Postgres is the database

Can I use a NULL value for a IN clause? example:

SELECT *
FROM tbl_name
WHERE id_field IN (\'value1\', \'value2\', \'value3\         


        
7条回答
  •  离开以前
    2020-11-30 00:54

    The question as answered by Daniel is perfctly fine. I wanted to leave a note regarding NULLS. We should be carefull about using NOT IN operator when a column contains NULL values. You won't get any output if your column contains NULL values and you are using the NOT IN operator. This is how it's explained over here http://www.oraclebin.com/2013/01/beware-of-nulls.html , a very good article which I came across and thought of sharing it.

提交回复
热议问题