Page 1 of 1

MySQL Search on TEXT field: words in any order

Posted: Wed Mar 10, 2010 3:50 am
by simonmlewis
Hello

I am sure I have posted this before but cannot find my post.

If a field contains "target gel", but someone searches for "gel target", in the usual:

Code: Select all

select * from table where name = '%$search%'
will not find the item.

I know there is a where with something like MATCH AGAINST, but I have tried and failed.
The fields being searched are set to TEXT.

How do you do it???

Re: MySQL Search on TEXT field: words in any order

Posted: Wed Mar 10, 2010 6:22 am
by s.dot
Google for a "php fuzzy search"

Re: MySQL Search on TEXT field: words in any order

Posted: Wed Mar 10, 2010 6:23 am
by pbs
You need to use MATCH ... AGAINST for your requirement.

For this your table type should be MYISAM and the searched field should have FULLTEXT index.