When columns in the database tables are not updated with the data then they usually contain Null values.
Null values cannot be used with comparison operators such as =, <, or <>.
We can only use "IS NULL" and "IS NOT NULL" operators.
Below is shown the "Authors" table:
White |
Michael |
22 Cleveland Av. #24 |
Berkeley |
Hunter |
Sheryl |
NULL |
Salt Lake City |
Smith |
Charlene |
NULL |
San Francisco |
Jhonson |
Fernandis |
2286 Cram Pl. #81 |
NULL |
Robert |
Paul |
1976 Arlington Pl. |
NULL |
Type or Copy the SQL into the Text Editor, click the "View Result" button, to see the result.
To retrieve all the records that has NULL value in the Address column.
SELECT * FROM Authors
WHERE Address IS NULL;
To retrieve the records that has NULL value in the City column.
SELECT * FROM Authors
WHERE city IS NULL;
To retrieve the records where the value is Not NULL in the Address column.
SELECT * FROM Authors
WHERE Address IS Not NULL;
SQL in Text Editor: