I have 190 table of one datebase, I would like to delete one data on each table. therefore,i use phpmyadmin tools but it only support delete data one by one I would like to delete each data of each table at a time. someone could help me? thank you
What are the table names, fieldname of table which has this data, and data you want to match? Can give you queries if you can give this info. Bye
thanks for your replies. my database info. Database "usexchange" Table " ADF,ADP,AED,AFN,AMD,ANG,AOA............etc 190" each table has two fied as "date","ex" I would like to delete data date(08-21-2007) from one database all of table. thank you
thanks for you both. I am no idea what to do it. Is there someone have syntax for phpMySQL? for instance DELETE FROM `database`.`All table` WHERE `date`='08-22-2007'
rps: drop will drop the whole table, not just one row.. adulu: I'm not familiar with mysql but on sql server there's a table 'systables' that has the name of each table.. find something similar in mysql. then you can make a dynamic query or small script that will loop on the output of a select of each table name and use that as input to make and run a delete query (in php or using sql script using a cursor)
Get your table name like below. While looping in table names, execute your delete queries for each table name... PS: You can use LIKE '%filter%' in show table command for filtering your tables. Check mysql documantation... <?php mysql_connect("localhost","root",""); $result = mysql_query("SHOW TABLE STATUS FROM test;"); while($array = mysql_fetch_array($result)) { echo $array[Name]; // Do your queries here.... } ?>
Hi, Try this: Save the following as a .php file somewhere on your server. Replace username, password, and add all table names where mentioned below. Then open script in browser like: http://www.yoursite.com/scriptname.php <?php mysql_connect("localhost","username","password"); //replace username with real username. password with real password. @mysql_select_db("usexchange"); $tables="ADF,ADP,AED,AFN,AMD,ANG,AOA"; //Enter all table names above seperated with a (,) sign $tables=explode(",",$tables); $a=""; foreach($tables as $v) { if($v!="") { mysql_query("DELETE FROM $v WHERE date='08-21-2007'"); $a=$a .','. mysql_affected_rows(); } } echo "Deleted: " $a; ?> Please back up your database first before doing this, incase you want the data back... Bye