Hey,
Is there a query I can run in phpMyAdmin to delete all tables with the prefix "mos_"? If there is, please provide the exact query as I can't code mySQL. Thanks. :)
Printable View
Hey,
Is there a query I can run in phpMyAdmin to delete all tables with the prefix "mos_"? If there is, please provide the exact query as I can't code mySQL. Thanks. :)
Hi,
I don't think there is any way to accomplish that using just one query. The only solution I can come up with is to make a script that obtain the tables with the prefix mos_ (using SHOW TABLES LIKE "mos_%"), and then creates a query which will drop the tables. If you need help what the script, let me know.
Yours, Erik.
Hi Erik,
Thanks for the offer - yes, I do need help with the script. I have absolutely no idea whatsoever how to code mySQL :p
Hi,
I think that something like the script below would work.
However, backup your database before running it, just in case.
Yours, Erik.PHP Code:<?php
mysql_connect('localhost', 'username', 'password');
mysql_select_db('your_database');
$tables = array();
$result = mysql_query('SHOW TABLES LIKE "mos_%"') or die(mysql_error());
while($table = mysql_fetch_row($result))
$tables[] = $table[0];
$delete = 'DROP TABLE '. implode(',', $tables);
mysql_unbuffered_query($delete) or die(mysql_error());
?>
Great script! No problems with it and now my DB is all cleaned up :)
Thanks alot, lilleman.