tags:

views:

6911

answers:

6

I know that probably it's not possible to do this, but just want to check it out with you, guys... Is it possible to do something like this, using MySQL? I want to search in all fields from all tables a given string:

SELECT * FROM * WHERE * LIKE '%stuff%'
+4  A: 

you can peek into the information_schema table. It has a list of all the tables and all the fields that are in the table. You can then run queiries using the information that you have gotten from this table.

Milhous
this is not the answer that I wanted, but I must accept the truth. :D Thank you
Armadillo
+1  A: 

You could use

SHOW TABLES;

Then get the columns in those tables (in a loop) with

SHOW COLUMNS FROM table;

and then with that info create many many queries which you can also UNION if you need.

But this is extremely heavy on the database. Specially if you are doing a LIKE search.

Ólafur Waage
+4  A: 

You can use this project: http://code.google.com/p/anywhereindb

This will search all the data in all table.

A: 

Other posts too: http://kedar.nitty-witty.com/blog/search-through-all-databases-tables-columns-in-mysql/

kedar
Unfortunely I couldn't get this to work using PhpMyAdmin. PhpMyAdmin does not allow you to 'CALL get_tables('search_string').
mathijsuitmegen
A: 

If you have phpmyadmin installed use it's 'Search' feature.

  • Select your db
  • Be sure you do have a DB selected and not a table...or you get a completely different search dialog
  • Click 'Search' tab
  • Choose the search term you want
  • Choose the tables to search

I have used this on up to 250 table/10GB databases (on a fast server) and the response time is nothing short of amazing.

Greg Lyon