MySQL REGEXP query - accent insensitive search

前端 未结 7 1920
清歌不尽
清歌不尽 2020-12-19 00:46

I\'m looking to query a database of wine names, many of which contain accents (but not in a uniform way, and so similar wines may be entered with or without accents)

7条回答
  •  感情败类
    2020-12-19 01:02

    To solve this problem, I tried different things, including using the binary keyword or the latin1 character set but to no avail.
    Finally, considering that it is a MySql bug, I ended up replacing the é and è chars,

    Like this :

    SELECT * 
    FROM `table` 
    WHERE replace(replace(wine_name, 'é', 'e'), 'è', 'e') REGEXP '[[:<:]]Faugeres[[:>:]]'
    

提交回复
热议问题