Home > other >  How to delete rows in MySQL with specific text
How to delete rows in MySQL with specific text

Time:08-15

Table Image

Hello! I'm trying to delete some rows within my file where the State_Name is United States and District of Columbia.

The database names I put as zzz_schema > Tables > 2017_annual

I've tried the delete from command but unfortunately with no luck. my code reads as below:

SELECT *
FROM zzz_schema.2017_annual
WHERE Measure_Name = 'Food Insecurity'
DELETE FROM 2017_annual WHERE State_Name = 'United States'

The first three lines gives me the correct table (attached as the picture) but I'm having trouble with deleting that specific stuff.

Thank you.

CodePudding user response:

Perhaps this is what you want:

DELETE
FROM zzz_schema.2017_annual
WHERE Measure_Name = 'Food Insecurity' AND
      State_Name IN ('District of Columbia', 'United States');

CodePudding user response:

May be this will work-

DELETE FROM zzz_schema.2017_annual
WHERE State_Name IN ("United States","District of Colombia");
  • Related