siliconpi siliconpi - 5 months ago 15
SQL Question

MYSQL query for searching through ALL the fields?

As dumb as it sounds, is there a way to do something like this:

select row_id from mytable where * like '%searched_text%';


By * here I mean "all the fields" in the table, instead of me specifying them one by one...

Answer

It is not possible with one query.

However when you do:

DESCRIBE table_name;

you get the field names which you can generate the query from.

http://stackoverflow.com/questions/639531/mysql-search-in-all-fields-from-every-table-from-a-database May be useful.