开发者

php/mysql: how to search case insentitively

开发者 https://www.devze.com 2022-12-10 17:01 出处:网络
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%\' .

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.


Use:

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

..or:

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

References:

  • LOWER
  • UPPER


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

utf8_ci

0

精彩评论

暂无评论...
验证码 换一张
取 消