mysql search - entire database

is there a way to search an entire mysql database for text if i don't know the table it's in?

say i wanted to search for "test" in my entire database, how would I do this?  is this possible?
LVL 1
bschwartingAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
psimationConnect With a Mentor Commented:
Hmm, I assumed you knew I was giving you a "pseudo php" method, but I see now that you posted in the MySQL DB section and linked to PHP as well.

I don;t think there is a solution in mysql only. You will need to write a script a language like PHP where you make use of some of it's built-in mysql functions to first get an array of tablenames, and then for fieldnames in each table. From that you would then use PHP to construct a SQL string that runs through all the possibilities. It's not going to be easy - I suggest you look at the php manual at php.net, and in particular, the mysql functions - there are some examples there already that you could use as the base of your script.
0
 
psimationCommented:
You will need to use mysql_list_tables() to get all the tables in your DB, then, inside another loop, you will have to use mysql_list_fileds() to find the fields in each table, and then only can you construct your SQL string in loops that will compare the text with each fieldname in each table.
0
 
bschwartingAuthor Commented:
can you give an example?
0
 
bschwartingAuthor Commented:
ok, thanks
0
 
black0psCommented:
bschwarting, did you accomplish this task and if you did, could you post your code?
0
All Courses

From novice to tech pro — start learning today.