PDA

View Full Version : Matches in any of the fields


guvenck
05-14-2008, 02:18 PM
I have lots of fields in a table where I keep a user's hardware configuration. Let's say, user_motherboard, user_gfxboard, user_optical, user_hdd...

I need a query that displays all the records that match a particular word in *any* of these fields (or fields I select).

For example, I need a query that looks for the matching records in user_motherboard, user_gfxboard and user_optical, for the word "gigabyte".

Can this be done in a single query or do I need to build loops for each field?

Any advices?

abduraooft
05-14-2008, 02:25 PM
you could use OR clause to join the fields like
where condition1 OR condition2 ....

PS: I'd recommend "Using MySQL Full-text Searching (http://devzone.zend.com/node/view/id/1304)"

nikos101
05-14-2008, 04:52 PM
Seems pretty tricky, especially if you wan to extract values form multiple columns