Like Case Sensitive in MySQL

后端 未结 8 2350
离开以前
离开以前 2020-11-29 06:38

I have a MySQL query:

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

And my table is encode

8条回答
  •  有刺的猬
    2020-11-29 07:13

    Just for completion, in case it helps:

    As stated on https://dev.mysql.com/doc/refman/5.7/en/case-sensitivity.html, for default character sets, nonbinary string comparisons are case insensitive by default.

    Therefore, an easy way to perform case-insensitive comparisons is to cast the field to CHAR, VARCHAR or TEXT type.

    Here is an example with a check against a single field:

    SELECT * FROM table1 WHERE CAST(`field1` AS CHAR) LIKE '%needle%';
    

提交回复
热议问题