Postgres NOT IN (null) gives no result

后端 未结 6 1341
长发绾君心
长发绾君心 2021-02-07 05:03

I\'m using Postgres with this query

select 
*
from Entity this_ 
where 
(this_.ID not in (null))

Why does this give me no results? I would expe

6条回答
  •  天涯浪人
    2021-02-07 05:21

    I have had similar in problem and eventually came up with the following solution;

    select * from public."Employee_11" where (COALESCE("Name",'@'),"Surname") 
        in (
            ('@','dummy')
        )
    

    It does return the records which Name column has null values. You can also use this for not in clause which will return not null records of Name;

      select * from public."Employee_11" where (COALESCE("Name",'@'),"Surname") 
            not in (
                ('@','dummy')
            )
    

提交回复
热议问题