jd2007 Posted August 5, 2007 Share Posted August 5, 2007 Is there a way to search all tables in a MySQL database ? Quote Link to comment https://forums.phpfreaks.com/topic/63404-is-there-a-way-to-search-all-tables-in-a-mysql-database/ Share on other sites More sharing options...
jd2007 Posted August 5, 2007 Author Share Posted August 5, 2007 i'm sorry...Is there a way to search all tables in a MySQL database for a particular column name ? Quote Link to comment https://forums.phpfreaks.com/topic/63404-is-there-a-way-to-search-all-tables-in-a-mysql-database/#findComment-315999 Share on other sites More sharing options...
Barand Posted August 5, 2007 Share Posted August 5, 2007 try <?php $column_name = 'name'; // col to search for $sql = "SHOW TABLES"; $res = mysql_query($sql) or die (mysql_error()."<p>$sql</p>"); while (list($table) = mysql_fetch_row($res)) { $sql2 = "DESCRIBE $table"; $res2 = mysql_query($sql2) or die (mysql_error()."<p>$sql2</p>"); while (list($field) = mysql_fetch_row($res2)) { if ($field==$column_name) { echo "\"$column_name\" found in table \"$table\"<br/>"; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/63404-is-there-a-way-to-search-all-tables-in-a-mysql-database/#findComment-316040 Share on other sites More sharing options...
jd2007 Posted August 6, 2007 Author Share Posted August 6, 2007 thanks Quote Link to comment https://forums.phpfreaks.com/topic/63404-is-there-a-way-to-search-all-tables-in-a-mysql-database/#findComment-316429 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.