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.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2996 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.