Search code examples
mysqlcase-sensitivesql-like

Like Case Sensitive in MySQL


I have a MySQL query:

SELECT concat_ws(title,description) as concatenated HAVING concatenated LIKE '%SearchTerm%';

And my table is encoded utf8_general_ci with MyISAM.

Searches seem to be case sensitive.

I can't figure out how to fix it. What's going wrong and/or how do I fix it?


Solution

  • Try this:

    SELECT LOWER(CONCAT_WS(title,description)) AS concatenated 
    WHERE concatenated LIKE '%searchterm%'
    

    or (to let you see the difference)

    SELECT LOWER(CONCAT_WS(title,description)) AS concatenated 
    WHERE concatenated LIKE LOWER('%SearchTerm%')