Jump to content

Is there a way to search all tables in a MySQL database ?


jd2007

Recommended Posts

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/>";
        }
    }
    
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.