How to handle null values ​​in WHERE IN conditions in mysql

I want to include the possible values ​​as null in the conditions of the mysql query.
This is my query: but it doesn’t show any values. Please suggest me how to write WHERE IN The condition contains null values.

SELECT * FROM TABLE1 WHERE COLUMN1 IN ('YES','NO',NULL);

Try something like this:

SELECT *
FROM TABLE1
WHERE (COLUMN1 IN ('YES','NO') OR COLUMN1 IS NULL)

The statement here will be parsed as COLUMN1 =’YES’ or COLUMN1 =’NO’ or field =’NULL’. Putting a NULL there will get COLUMN1 = null, which will be invalid.

I want to include the possible values ​​in the conditions of the mysql query as null.
This is my query: but it does not show any value. Please suggest me how to include a null value in the WHERE IN condition.

SELECT * FROM TABLE1 WHERE COLUMN1 IN ('YES','NO',NULL);

Try something similar:

SELECT *
FROM TABLE1
WHERE (COLUMN1 IN ('YES','NO') OR COLUMN1 IS NULL)

The statement here will be parsed Is COLUMN1=’YES’ or COLUMN1=’NO’ or field=’NULL’. Putting a NULL there will get COLUMN1=null, which will be invalid.

Leave a Comment

Your email address will not be published.