比较字符串时的逻辑相同

时间:2016-09-30 09:02:38

标签: php mysql encoding

在mysql中,如果你这样做:

CREATE TABLE `foo` (`text` VARCHAR(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `foo` (`text`) VALUES ('Foo'), ('foo'), ('tel'), ('tél');

SELECT `text`, COUNT(*) AS `num` FROM `foo` GROUP BY `text`

你会得到这个:

+------+-----+
| text | num |
+------+-----+
| Foo  |   2 |
| tel  |   2 |
+------+-----+

或:

SELECT * FROM `foo` WHERE `text` = 'tel';

结果:

+------+
| text |
+------+
| tel  |
| tél  |
+------+

现在,在php中,有没有办法获得类似的

E.g。检查'tel''tél'是否相等会导致true

0 个答案:

没有答案