9

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

1
  • Possibly "%oftware%"? Of course that might clash with any number of similarities... Commented Aug 3, 2011 at 20:48

2 Answers 2

8

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)

Sign up to request clarification or add additional context in comments.

1 Comment

unless its a *_bin collation, but you can still specify which collation should be used in the query, even if column in question uses case sensitive one.
8

You can always try

LOWER(cd.name) LIKE '%software%'

2 Comments

How to use it with a Python query string?
@parsecer, this is worth its own question. If crating your own SQL string you can use the SQL LOWER function in it. If you are doing a parameter based query, just use Python's string.lower() to lower case the string before feeding it into the parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.