0

i have this table in UTF8 (collation is utf8_bin in case it matters).

I need to search in it for strings using LIKE '%$searchstring%' .

Right now you have to use the exact case in order for the results to show up. Is there a way to make it case insensitive ?

Thank you

UPDATE sorry, found the answer.

2 Answers 2

2

Use:

WHERE LOWER(t.column) LIKE LOWER('%search_string%')

..or:

WHERE UPPER(t.column) LIKE UPPER('%search_string%')

References:

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

2 Comments

according to stackoverflow.com/questions/234591/upper-vs-lower-case/…, comparison with 'lower' or 'upper' can be incorrect for some languages
What about ... (etc COLLATE utf8_<lang>_ci) LIKE '%searchstring%'? By the way, if you want "Çilek" to show up in results when the user searches for "cilek", you can use utf8_unicode_ci, that is, both case insensitive and collation insensitive search.
0

Your collation specifies the case-sensitivity. Use this instead:

utf8_ci

Comments

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.