EN
MySQL - select only rows where removal_time is NULL
1 answers
3 points
How to select only rows where removal_time is NULL with MySQL?
Doesn't work:
xxxxxxxxxx
1
SELECT * FROM qa_post_comments WHERE removal_time = NULL;
It can be executed, but it doens't return any values at all - NULL or NOT NULL.
How to make it work?
1 answer
1 points
Correct SQL:
xxxxxxxxxx
1
SELECT * FROM qa_post_comments WHERE removal_time IS NULL
Where we want to select rows with only NULL values:
xxxxxxxxxx
1
IS NULL
And if we want to select rows with NOT NULL values:
xxxxxxxxxx
1
IS NOT NULL
Eg:
xxxxxxxxxx
1
SELECT * FROM qa_post_comments WHERE removal_time IS NOT NULL
Is is very common mistake and a lot of people try to use:
- = NULL
- != NULL
0 commentsShow commentsAdd comment