Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i do a case insensitive mysql contains string

Tags:

mysql

I am doing a query that needs to search if the work software is in the string...the only problem is that it maybe upper or lower case so i was thinking of doing this

and (cd.name LIKE '%software%' or cd.name LIKE '%Software%' )

but i feel like there is another way if anyone knows

like image 640
Matt Elhotiby Avatar asked Aug 03 '11 20:08

Matt Elhotiby


1 Answers

MySQL is case insensitive.

These will give the same results, so you can use either: cd.name LIKE '%software%' cd.name LIKE '%Software%'

That's what the 'ci' is for in the different collations (latin1_general_ci, latin1_swedish_ci)

like image 136
Parris Varney Avatar answered Sep 24 '22 17:09

Parris Varney