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
  • 300 Users Found This Useful
Was this answer helpful?

Related Articles

How to flush your DNS cache

Your home computer creates a cache for all DNS settings. It does this to save time each time you...

What is the root login for my new VPS server?

The root login is the same password our system sent you in your welcome email. You just change...

What is the path to PERL?

The path to PERL in PERL script is:#!/usr/local/bin/perl

Do you troubleshoot scripts and apps?

Hello,Sorry, but troubleshooting sripts and apps needs to be done by the scipt maker or a...

How to use PHP-CLI

You would call '/usr/local/bin/php' if you need the php-cli binary, and '/usr/bin/php' if you...