WHERE field1 IN (NULL)

萝らか妹 提交于 2019-12-02 04:05:46

Try IS NULL

SELECT * FROM XYZ 
WHERE col1 IN ('a', 'b') 
AND col2 IN ('c', 'd') 
AND col3 IS NULL   -- Instead of IN (NULL)

for each column test it against your parameter and include the IS NULL test, combine these with parentheses, like this:

SELECT
      *
FROM XYZ
WHERE (col1 IN ('a', 'b') OR col1 IS NULL)
  AND (col2 IN ('c', 'd') OR col2 IS NULL) 
  AND (col3 IN (NULL) OR col3 IS NULL)

here col3 IN (NULL) is used to demonstrate a parameter that was not provided

Jayvee

something like this should work:

SELECT * FROM XYZ
WHERE ISNULL(col1,'') IN ('a', 'b','')
AND   ISNULL(col2,'') IN ('c', 'd','')
AND   ISNULL(col3,'') IN ('')
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!