Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select rows where column is null

Tags:

sql

How do you write a SELECT statement that only returns rows where the value for a certain column is null?

like image 842
anjum Avatar asked Jul 30 '10 06:07

anjum


People also ask

WHERE column is NULL MySQL query?

To search for column values that are NULL , you cannot use an expr = NULL test. The following statement returns no rows, because expr = NULL is never true for any expression: mysql> SELECT * FROM my_table WHERE phone = NULL; To look for NULL values, you must use the IS NULL test.

How do I get columns with NULL values?

You can use df. isnull(). sum() .


1 Answers

Do you mean something like:

SELECT COLUMN1, COLUMN2 FROM MY_TABLE WHERE COLUMN1 = 'Value' OR COLUMN1 IS NULL 

?

like image 72
Jon Skeet Avatar answered Oct 04 '22 12:10

Jon Skeet