Frequently Asked Questions

What is the mysql command to delete all rows with a certain string?

The magic query to delete a row based on your custom settings is:

delete from [table name] where [column name] like '%[text to find]%'

You'll need to understand how this works to change the variables.

delete - means to delete a row

[table name] - this is the table you want to search in

[column name] - this is the column you want to search in

%[text to find]% - this field needs the % characters on either side of the keyword to search for all strings with that word in it.

In this working example, spammers added thousands of users with a blog name in the username. We went into phpmyadmin and ran a quarry to remove them all with this code:

delete from wp_users where user_login like '%blogname%'

 

  • mysql, string, row, query, delete, remove, bulk, quarry

Was this answer helpful?

300 Users Found This Useful