Reputation: 92
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.
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
1) Which table "value1" exist. 2) For which field this data is been stored.
I am hopeful you got things I am looking for. Thanks in advance :)
Upvotes: 3
Views: 325
Reputation: 27354
You should take a look at below link.
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('stackoverflow')or die(mysql_error());
$sql = "SHOW TABLES FROM stackoverflow";
$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.
Upvotes: 3