On 21 Aug 2002, at 16:27, tibyke wrote:

> > $keyword = "search";
> > SELECT * FROM table WHERE field LIKE '%$keyword%'
> > 
> > The problem is I don't want "sear" or earch but exactly "search".
> 
> like "% $keyword %";

But that won't find "search" if it's at the beginning or end of a 
string, or preceded or followed by punctuation.

Robert's question is strange, because "field LIKE '%search%'" 
shouldn't be finding anything with just "sear" or "earch".  If his 
real question is how to avoid finding "research" or "searching", then 
the best answer is probably a full-text index:

http://www.mysql.com/doc/en/Fulltext_Search.html

That will also be a lot faster than using LIKE if his tables are at 
all large.

-- 
Keith C. Ivey <[EMAIL PROTECTED]>
Tobacco Documents Online
http://tobaccodocuments.org

---------------------------------------------------------------------
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