3

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 :)

4
  • Have you tried something? Do you want to do it all in MySQL or with Java/C#/.NET/... ? Commented Mar 1, 2013 at 7:48
  • 1
    stackoverflow.com/questions/639531/… Commented Mar 1, 2013 at 7:53
  • @araknoid I am working on a CMS based upon PHP and MSQL, actually there is very less support available to working on CMS,so am trying to find out things how it's workflow. Commented Mar 1, 2013 at 7:56
  • @Deadlock thanks :) to still I am having bit confusion will let know you if i'd have any query Commented Mar 1, 2013 at 7:57

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

You can add a loop on mysql_fetch_field in the mysql_fetch_row loop, in order to lookup for the field name.
@djleop yes we can i just put much effort to gave him solution if i wrote every code for him then OP will not learn anything..my best try for answering is let OP to learn by himself..
me too looking to develop my skills

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.