Search for whole words in MySQL 3.23
| From: | Zeth Lietzau | Date: | Wed, 13 Jun 2007 20:19:11 +0000 |
| Subject: | Search for whole words in MySQL 3.23 | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-43679@lists.php.net to get a copy of this message | ||
Hi all,
I'm setting up a database search on a site, where I will essentially be
BOOLEAN searching about 6 database fields. Unfortunately, the database I'm
using is MySQL version 3.23 (completely out of my control), so I cannot use
IN BOOLEAN MODE to simplify the process on my end. I've been able to put
together a function that does almost everything that I want, but I'm running
into a problem - searching for whole words that may or may not be in the
beginning or end of the database field. For example, syntax like this:
...WHERE
field LIKE '%searchterm%'...
has the limitation that if the search term is 'car', it will also bring back
'scar', 'cartoon', etc.
While if the syntax is:
...WHERE field LIKE '% searchterm %'... (with spaces)
it misses words that are the first or last words of the field, or words that
are at the end of sentences, before commas, etc.
I've looked around and haven't been able to find a way to search only for
complete words within a block of text. Any help?
Thanks in advance,
Zeth