MySQL diacritic insensitive search (spanish accents)

前端 未结 5 752
孤街浪徒
孤街浪徒 2020-11-29 07:48

I have a MySQL database with words containing accents in Spanish (áéíóú). I\'d like to know if there\'s any way to do a diacritic insensitive search. For instance, if I sear

5条回答
  •  佛祖请我去吃肉
    2020-11-29 08:18

    You can force the column name to convert as UTF8. I haven't tried is for Spanish but rather for Romanian characters with accents, but I assume it's the same thing.

    The query I use is:

    SELECT CONVERT('gîgă' USING utf8) LIKE '%giga%'
    

    Or in the more likely case of looking up a column in a table, you can use:

    SELECT CONVERT(column_name USING utf8) FROM table_name LIKE '%giga%'
    

提交回复
热议问题