MySQL – Delete Rows from Table where Column is NULL
To delete rows of a table where the value of a specific column is NULL in MySQL, use SQL DELETE statement with WHERE clause and the condition being the column value is NULL.
The following is a simple syntax of DELETE statement with WHERE clause to delete rows from table where there is NULL in the column.
DELETE FROM table_name column_name IS NULL ;
- table_name is the table name from which we would like to delete the rows.
- column_name is the name of column whose value has to be checked if it is
In the following example, we will consider a table
students and remove the rows where there is
NULL in the
“students” table before DELETE
name rollno Arjun 14 Manish 15 Vina 16 NULL 17 NULL 18
DELETE FROM students WHERE name IS NULL;
2 row(s) affected
“students” table after DELETE
name rollno Arjun 14 Manish 15 Vina 16