Mysql utf8mb4 equality

371 views Asked by At

I am storing text with emojis in a mysql database.

The database, table and column are set to use utf8mb4 and utf8mb4_unicode_ci.

I can enter the cell values without a problem (datatype is VARCHAR).

However, when I try to query the database and differentiate between emoji types, mysql can't differentiate.

For example, if I query the database for the row where emoji_column = 'hello' Then it will return all rows that have 'hello' and any emoji appended to it (eg: 'hello', 'hello', etc.).

Is this normal behavior? Do I have to compare the Hex values if I want an accurate query? Or is something not set up correctly?

(The emojis are stored correctly, that is, if I query the database by some other parameter, then the correct emoji is returned).

Thanks.

1

There are 1 answers

4
Rick James On

I think you need COLLATION utf8mb4_unicode_520_ci to distinguish Emoji.