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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case Sensitivity problem with LIKE... 1

Status
Not open for further replies.

ChrisMacPherson

Programmer
Jul 3, 2000
157
GB
I am having difficulty understanding my results when I enter search terms in to my LIKE statement (using PHP here).

My statement is :

Code:
"SELECT stuff
FROM table
WHERE status = 'active' AND areaInfo LIKE '%" . $searchTerms . "%'";


If I use "Golf" as $searchTerms I get 3 results
If I use "golf" as $searchTerms I get 4 results

It says in the mysql manual, that LIKE is case-insensitive. How can this be?

Any suggestions how to achieve real case-insensitivity?

Chris MacPherson


 
I will get the results in a sec, just had a thought:

I am searching for a match in a blob, is this possibly why this behaviour occurs, as a blob is case-sensitive.

Chris MacPherson


 
Cool, that's that sorted. I am going to to convert both to lowercase and then perform the search.

Do you reckon this will be the best solution to get around this? Any known remedies?

Thanks for your time.




Chris MacPherson


 
areaInfo sounds like it should be TEXT, not BLOB

look up TEXT and you will see that while you can store your data in mixed case, searches are case-insensitive

which sounds like what you want anyway

so, no, i wouldn't lowercase the data

rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts March 6 2005)
 
Ah ha. I slightly misunderstood what I read then. Thanks a lot, I'm sure that should work as you suggest.



Chris MacPherson


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top