Searching MySQL using LIKE
| From: | Jordan Elver | Date: | Fri, 21 Sep 2001 16:03:15 +0000 |
| Subject: | Searching MySQL using LIKE | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-12631@lists.php.net to get a copy of this message | ||
Hi,
I'm cross posting this because it's applicable to both list ;-)
I have a table which contains a field called Keywords. The field typically
contains something similar to this "rubbish bins trash"
I want to search this field and I'm having trouble. If someone enters "I need
bins" then the the result will not be found.
I started off by using SELECT * FROM table WHERE keywords LIKE '%keyword%',
but that doesn't work if you type in more than just bins. So then I tried
splitting the words entered on a space and searching for each of them like
this SELECT * FROM table WHERE keywords LIKE '%keyword1%' OR keywords LIKE
'%keyword1%'. But that returns loads of results because a lot of words
contain "is" or "it" etc.
Can anyone help me with this one, I'm not sure what to try next?
Cheer,
Jord
--
Jordan Elver
Web Developer
The InternetOne UK Ltd