> I guess this is easy, but it is defeating me.
> I am having a problem with this query:
>
> $keyword = "search";
> SELECT * FROM table WHERE field LIKE '%$keyword%'
>
> The problem is I don't want "sear" or earch but exactly "search".

If you're looking for an exact match, where field will contain NOTHING BUT
the $keyword, then:

   WHERE $field = '$keyword'

But if you're looking within a sentence or paragraph of text, try
something like this (double-bracket POSIX regexp -- to be honest, I just
found this online, and so far it appears to work -- if anyone could
expound on the :<: and :>: that would be swell:

   WHERE $fields REGEXP '[[:<:]]$keyword[[:>:]]'

Regards,
Neil Mansilla
whatUseek.com




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to