3

I have a table with a column meta_key … I want to delete all rows in my table where meta_key matches some string.

enter image description here

For instance I want to delete all 3 rows with "tel" in it - nut just the cell but the entire row. How can I do that with a mysql statement?

2

5 Answers 5

5

The below query deletes the row with strings contains "tel" in it :

   DELETE FROM my_table WHERE meta_key like '%tel%';

This is part of Pattern matching.

If you want the meta_key string to be equal to "tel" then you can try below:

   DELETE FROM my_table WHERE meta_key = 'tel'

This is a simple Delete

Sign up to request clarification or add additional context in comments.

Comments

1
delete from tablename where meta_key = 'tel'

Comments

1
DELETE FROM `table_name` WHERE meta_key = "tel";

For the future, try and read the docs.

Comments

1
DELETE FROM table
        WHERE meta_key= 'tel';

In addition you can use limit to specify the amount of rows to delete

Comments

1
DELETE FROM table WHERE meta_key = 'tel' //will delete exact match

DELETE FROM table WHERE meta_key = '%tel%'//will delete string contain tel

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.