Shades
Shades

Reputation: 285

Deleting row with a blank column value

I have a person table in SQL and i have columns: id, lastname, firstname, address, city. City for a person is empty so i want a query to delete the row containing the person with a blank city column value. The code below didn't do it even though no errors were raised.

DELETE FROM persons pers
WHERE lastname = 'saire' AND address = 'NULL'

Upvotes: 0

Views: 12677

Answers (2)

Eric_ph
Eric_ph

Reputation: 128

$q = "DELETE FROM `table_name` WHERE `city` =''";

Upvotes: 0

rvphx
rvphx

Reputation: 2402

The following SQL command should remove all records with a null value for city. Try this.

DELETE FROM persons
where city IS NULL

Upvotes: 2

Related Questions