'DELETE FROM `table` WHERE `field`= nothing

How do I delete all rows that have a field called A that are blank.

Lets say I have a table that looks like the following.

|ID   |A   |B   |C
|1    |Data|Data|Data
|2    |    |Data|Data
|3    |Data|    |Data
|4    |    |    | 

So in the above example row 2 and 4 would be removed because there isn't anything stored in them?

How can I do this I'm doing I'm thinking something along the lines of the following.

Okay setup another table and tried the following.

DELETE FROM `table` WHERE `A`= ''

Is that that correct?



Solution 1:[1]

It's hard to tell from what you provided because ...blank... can be interpreted in various ways but may be you are looking for something like this

DELETE 
  FROM Table1
 WHERE CHAR_LENGTH(COALESCE(TRIM(A), '')) = 0

What it does it deletes all rows that have in column A

  1. NULL values
  2. empty string values
  3. values that consist of only spaces

Here is SQLFiddle demo

Solution 2:[2]

You can use both

DELETE FROM `table` WHERE A = '';

or

DELETE FROM `table` WHERE A IS NULL;

Solution 3:[3]

DELETE FROM TABLENAME
WHERE A IS NULL OR TRIM(A) = '';

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 aizaz
Solution 3 Darshan Mehta