I have a database which store old installation wordpress tables.
I would like to clean up a bit so I am looking for a query can delete the table based on the prefix table name.
In this case I want to drop all table that start with “_wordpress_1_”
_wordpress_1_eruiweuriw
_wordpress_2_jshfiojdwi
_wordpress_1_fksdjfksdj
_wordpress_1_fskdjfksdf
_wordpress_3_kfsjdfsdkf
So iam trying:
USE database_name;
SELECT * FROM database_name WHERE TABLE_NAME LIKE '%_wordpress_1_%';
I guess i cannot use like in the where statement for table name but just for table column??
Could I get any tips on how to achive this?
2
Answers
you don’t can do it with only one MySQL Command, you can use MySQL to construct the statement for you:
In the MySQL shell or PHPMyAdmin, Paste the following query with changing the prefix :
This will generate a DROP statement which you can than copy and execute to drop the tables.
then