Languages

MySQL - select only rows where removal_time is NULL

3 points
Asked by:
Root-ssh
91810

How to select only rows where removal_time is NULL with MySQL?

Doesn't work:

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
Answered by:
Root-ssh
91810

Correct SQL:

SELECT * FROM qa_post_comments WHERE removal_time IS NULL

Where we want to select rows with only NULL values:

IS NULL

And if we want to select rows with NOT NULL values:

IS NOT NULL

Eg:

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 comments Add comment
Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join