Using LIKE command in MySQL giving weird results
I'm new to MySQL, but have used Access for many years in intranet
development. Recently started using a MySQL database and pulling my hair
out. The LIKE command is giving erratic or no results for records that do
exist.
A table called "Clients", containing a column called "BusinessName". One
record is for example "FRED SMITH CONSTRUCTIONS".
Select * from Clients where BusinessName LIKE '%FRED%' returns true.
Select * from Clients where BusinessName LIKE '%FRED SMITH%' returns false!
Select * from Clients where BusinessName LIKE '%FRED%SMITH%' returns false!
Select * from Clients where BusinessName LIKE '%FRED%S%' returns true.
Select * from Clients where BusinessName LIKE '%FRED%SM%' returns false!
Select * from Clients where BusinessName LIKE '%FRED%S%C%' returns true.
Its pretty erratic, and makes no sense to me at all. Any more than 1 word
and it seams to get confused. Its like the % wildcard doesn't work between
words, or if there is more than one character in the 2nd word.
To get me out of trouble I'm searching for each word separately, but this
shows too many results. eg
Select * from Clients where BusinessName LIKE '%FRED%' or BusinessName
LIKE '%SMITH%' returns true.
Any suggestions? The column type is Text. Tried RLIKE with similar results.
Regards Glenn
No comments:
Post a Comment