RE: [PHP-DB] Searching MySQL using LIKE
| From: | Jason Wong | Date: | Fri, 21 Sep 2001 11:09:54 +0000 |
| Subject: | RE: [PHP-DB] Searching MySQL using LIKE | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-12632@lists.php.net to get a copy of this message | ||
>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?
The obvious first thing to do is to screen your keywords. Do not search on
common words such as:
and, if, the, in etc.
hth
--
Jason Wong
Gremlins Associates
www.gremlins.com.hk
Tel: +852-2573-5033
Fax: +852-2573-5851