0

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.

Manesh
  • 586
  • 3
  • 14
  • 31

3 Answers3

1

Use upper() function to make both strings to upper case:

Select * from Cat where upper(name)=upper('book')
Jens
  • 67,715
  • 15
  • 98
  • 113
0

If I understand correctly you can use the upper or lower function in the comparison

Fusi123
  • 77
  • 1
  • 6
0

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

Juan
  • 588
  • 1
  • 8
  • 25