jd2007 Posted August 5, 2007 Share Posted August 5, 2007 Is there a way to search all tables in a MySQL database ? 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 ? 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/>"; } } } ?> 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 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
Archived
This topic is now archived and is closed to further replies.