Reputation: 596
I have written an ajax function to check if a value exists inside the database.
For example consider two strings "Book" and "book". In my current situation "Book" is there inside the Database and if I search using the query below
Select * from Cat where name='book'
OR
Select * from Cat where name like 'book'
It returns an empty result set since the 'b' is in lowercase. My collation is utf8_bin. What will be the query to evaluate in such a way that it will be the same whether it is upper case or lower case.
Upvotes: 0
Views: 112
Reputation: 588
Use LIKE
instead =
http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html
Or also convert everythiing to upper/lower before comparing
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_upper
Upvotes: 0
Reputation: 87
If I understand correctly you can use the upper or lower function in the comparison
Upvotes: 0
Reputation: 69440
Use upper()
function to make both strings to upper case:
Select * from Cat where upper(name)=upper('book')
Upvotes: 1