0

I have a table with text that certainly will have accents áéíóú etc in the text.

However another system that is connected to this has problems managing accents.

I am creating a View so that this system connects to that view, but I want to remove the accents from the query.

Is there a way to replace those characters on a query? (original data must not be transformed)

Let's say transform:

Héctor
Pablo
Pedro
María

to

Hector
Pablo
Pedro
Maria
4

1 回答 1

0

执行此操作的标准方法是应用 Unicode 分解规范化,然后过滤掉组合字符。MySql 不支持规范化(或 REGEXP_REPLACE 或 TRANSLATE)。

但是,如果您只有几个与您有关的组合字符和组合字符,则 REPLACE 应该可以很好地工作。

SELECT 
  data,
  REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(data, 
    'á', 'a'),
    'é', 'e'),
    'í', 'i'),
    'ó', 'o'),
    'ú', 'u'),
    convert(0xcc81 using utf8), '') -- 'COMBINING ACUTE ACCENT' (U+0301)
FROM test;

SQL小提琴

于 2018-02-17T18:37:13.040 回答