0

INSERT INTO table_name (col_name) VALUES ('');

SELECT * FROM table_name WHERE col_name = '';

I my opinion no row has to be returned from the second query, but is returned.

The table is utf8mb4 with collation utf8mb4_unicode_ci.

Is something related to ci? I would like to keep it.

Arjan
  • 9,784
  • 1
  • 31
  • 41
user3396065
  • 549
  • 5
  • 15
  • Are you using MySQL or MariaDB? Even though MariaDB is (supposed to be) a drop-in replacement for MySQL, I would expect that in situations like this the behaviour might be different, so one of the tags should be removed. – Arjan Apr 14 '16 at 22:01

1 Answers1

0
SELECT '' = '' COLLATE utf8mb4_unicode_ci,
       '' = '' COLLATE utf8mb4_unicode_520_ci;

Yields 1 and 0.

That is, utf8mb4_unicode_ci treats Emoji as equal, but utf8mb4_unicode_520_ci treats them as different.

So, change the collation of col_name to utf8mb4_unicode_520_ci.

Rick James
  • 135,179
  • 13
  • 127
  • 222