I have a large mySQL database and I want to remove every record that is empty, not null in a certain column. What is the best way to do write a SQL query for this?
Currently I have tried:
DELETE FROM Businesses WHERE WEBADDRESS IS NULL
But it did not delete anything. There are 44,000 records and almost 80% of them are null in that column.
DELETE FROM myTable WHERE myColumn IS NULL
Link to MySQL page for DELETE syntax: http://dev.mysql.com/doc/refman/5.7/en/delete.html
IF the column is not NULL
but just blank you would need to do something like:
DELETE FROM myTable WHERE myColumn = ''
Based on the information you also provided in the comments, the values are likely being loaded as empty (''
) and not NULL
: http://dev.mysql.com/doc/refman/5.7/en/problems-with-null.html
The second query should work.
delete from your_table
where certain_column is null
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With