如何从MySQL数据库中查找表和字段?

时间:2021-09-13 19:14:08

I am working on a MySQL based project, in which I have 57 tables in my database. I need to find table/tables and field from database on basis of stored data.

我正在做一个基于MySQL的项目,我的数据库中有57个表。我需要根据存储的数据从数据库中查找表/表和字段。

I want to describe my problem here.

我想描述一下我的问题。

Let I have data "value1" in a field in one of 57 tables of my database, I just know there is data "value1" somewhere in my database, now on basis of "value1" I want to find out

让我在我的数据库的57个表中的一个字段中有数据“value1”,我只知道在我的数据库的某个地方有数据“value1”,现在基于“value1”我想要找到它

1) Which table "value1" exist. 2) For which field this data is been stored.

1)存在哪个表“value1”。2)该数据存储在哪个字段。

I am hopeful you got things I am looking for. Thanks in advance :)

我希望你有我要找的东西。提前谢谢:)

1 个解决方案

#1


3  

You should take a look at below link.

你应该看看下面的链接。

http://code.google.com/p/anywhereindb/

http://code.google.com/p/anywhereindb/

OR

<?php  
    $search_word = 'new.example.com';
    mysql_connect($host, $username, $password);

    $connection = mysql_connect('localhost','root','')or die(mysql_error());
    $database   = mysql_select_db('*')or die(mysql_error());

    $sql = "SHOW TABLES FROM *";
    $tables_result = mysql_query($sql)or die(mysql_query());



    echo "Look for '$search_word'\n\n";
    while ($table = mysql_fetch_row($tables_result))
    {
        echo "Table: {$table[0]}\n";
        //serach query for tables $table[0]     
    }
    mysql_free_result($tables_result);  
?>

use mysqli_* or PDO because mysql_* is deprecated.

使用mysqli_*或PDO,因为不赞成使用mysql_*。

#1


3  

You should take a look at below link.

你应该看看下面的链接。

http://code.google.com/p/anywhereindb/

http://code.google.com/p/anywhereindb/

OR

<?php  
    $search_word = 'new.example.com';
    mysql_connect($host, $username, $password);

    $connection = mysql_connect('localhost','root','')or die(mysql_error());
    $database   = mysql_select_db('*')or die(mysql_error());

    $sql = "SHOW TABLES FROM *";
    $tables_result = mysql_query($sql)or die(mysql_query());



    echo "Look for '$search_word'\n\n";
    while ($table = mysql_fetch_row($tables_result))
    {
        echo "Table: {$table[0]}\n";
        //serach query for tables $table[0]     
    }
    mysql_free_result($tables_result);  
?>

use mysqli_* or PDO because mysql_* is deprecated.

使用mysqli_*或PDO,因为不赞成使用mysql_*。