Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with LIKE clause in query

Status
Not open for further replies.

CliffLandin

Programmer
Nov 14, 2004
81
US
I am encountering a strange issue. I am querying a mysql database for keyword results using:

Code:
SELECT * FROM table WHERE title LIKE '%keyword%'

and it works fine...

but only for certain words. For example, I have 2 properties, Viking Lodge #213 and Franz Klammer Lodge. If I search for Viking all of the Viking properties including #213 come up. If I do a search for Lodge both of the above units plus all the ones with Lodge in the title are returned.

However, if I search for Franz or Klammer I get no results back.

Certain words will return results, but other words that should, won't.

I'm at a loss. Any help would be appreciated.

Thanks,

When in doubt, go flat out!

 
Hi

Did not measured it properly in MySQL, but usually functions are faster than regular expressions. For what you showed us the [tt]locate()[/tt] function is enough :
Code:
[b]select[/b] * [b]from[/b] table [b]where[/b] locate([i]'keyword'[/i],title)!=0
Do you have the issue with this too ?

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top