If we have a table with null value, the row can be filtered out using is null or is not null.
CREATE TABLE artist ( id int auto_increment primary key, artiste varchar(30), album varchar(50), year int(10) ); INSERT INTO artist (artiste, album, year) VALUES (null, 'Maggie May', 1973), ('New Order', 'Substance', 1987), ('Nirvana', 'Smell Like Teen Spirit', 1992);
The query statement is:
select * from artist where artiste is null
select * from artist where artiste is not null
Note that you can’t use comparison operator (such as
<>) to check for null. This is a common mistake.
For example, the query below will return 0 record.
select * from artist where artiste is = null