views:

25

answers:

2

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...

+1  A: 

Yes, it's called Full Text Search.

You can use MySQL's built-in Full Text Search, or use a separate product to do you text indexing such as Apache's Lucene (my personal favorite).

Pablo Santa Cruz
umm - hi Pablo - how do I use it? It sounds like I need to modify my columns?
matt_tm
Full Text doesn't help, you still have to enumerate all the fields you search in.
Wikeno
@matt_tm, you don't need to modify your columns, you just need to create a FULL TEXT index on all the columns you want to search. It's like creating an index.
Pablo Santa Cruz
@Wikeno: true. But I think he's trying to avoid a **HUGE** where clause here, concatenated by **OR** conditions... I might be wrong though...
Pablo Santa Cruz
A: 

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.

Wikeno
the linked question is exactly what my question is... thanks wikeno
matt_tm