Matthieu Gaillet
Matthieu Gaillet

Reputation: 123

MariaDB/MySQL : replacing an unicode character by another one doesn't work (0 rows affected)

I'm trying to replace every occurence of the unicode character "MINUS SIGN" (U+2212) by 'HYPHEN-MINUS' (U+002D) into a column.

I tried various flavours of UPDATE..REPLACE commands, like :

UPDATE assets 
SET 
    asset_tag = REPLACE(asset_tag,
        concat("%", unhex('e28892'), "%"),
        concat("%", unhex('2d'), "%"))
WHERE
    asset_tag like concat("%", unhex('e28892'), "%");

All yields to the same result :

Query OK, 0 rows affected (0.00 sec)
Rows matched: 412  Changed: 0  Warnings: 0

The table's charset is DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

What am I doing wrong ? I'm using the command line client.

Thanks !

Upvotes: 0

Views: 547

Answers (1)

Shamuwel Ansari
Shamuwel Ansari

Reputation: 26

You don't need '%' in REPLACE. So just make your replace function like this: REPLACE(assert_tag, unhex('e28892'), unhex('2d'))

Upvotes: 1

Related Questions