I see. What about something like this, then:
Where title=VAR or left(title,length(VAR)+1)=concat(VAR," ") or
right(title,length(VAR)+1)=concat(" ",VAR) or title like "% VAR %"
Does that one work?
Jed
On the threshold of genius, Rob Gambit wrote:
>> WHERE ((title like '%man%') or (title like '%men%'))
>> and title not like
>> '%woman%' and title not like '%women%'
>>
>> Does that work? HTH!
>
> No, but I forgot to mention that I don't know what the
> keywords are before hand. They will be typed in by the
> user.
>
> Like if the user types in a keyword of "cat" I want to
> only return titles with the word "cat" but not "cats"
> or "catalog"
>
> I had thought to search for '% cat %' but the keyword
> could be at the beginning of the title, or the end, be
> followed by a . or a space. *shrug* probably need to
> think up something with RLIKE maybe.
>
> --- Jed Verity <[EMAIL PROTECTED]> wrote:
>> Hi, Rob,
>>
>> Easily resolved. Use 'not like' in conjunction with
>> 'like':
>>
>> WHERE ((title like '%man%') or (title like '%men%'))
>> and title not like
>> '%woman%' and title not like '%women%'
>>
>> Does that work? HTH!
>> Jed
>>
>> On the threshold of genius, Rob Gambit wrote:
>>
>>> Hello MySQL mailing list.
>>>
>>> I am having trouble creating a SQL statement for
>>> searching.
>>>
>>> Suppose I have a field named title that contains
>> one
>>> of these
>>> I am a Man
>>> I am a Woman
>>> We are Men
>>> We are Women
>>>
>>> Now I am trying to search that field using
>> keywords,
>>> for example, I want to return any that contain the
>>> word "man" or "men" but not "woman" or "women"
>>>
>>> WHERE (title LIKE 'man') OR (title LIKE 'men')
>>>
>>> but that doesn't return anything. I tried
>>>
>>> WHERE (title LIKE '%man%') or (title like '%men%')
>>>
>>> but that returns everything. I tried using the _
>>> instead of % but the word may or may not be at the
>> end
>>> or beginning of the line.
>>>
>>> Can someone point me in the right direction (or
>> tell
>>> me how to do it)
>>>
>>> Thanks. Sorry for the newbie question.
>>>
>>> Robert
>>>
>>>
>>> __________________________________________________
>>> Do You Yahoo!?
>>> Yahoo! Finance - Get real-time stock quotes
>>> http://finance.yahoo.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
>>>
>>>
>>
>>
>>
> ---------------------------------------------------------------------
>> 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
>>
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes
> http://finance.yahoo.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