MySQL 8.4 发行说明
使用 COLLATE
子句,您可以覆盖比较的默认排序规则。 COLLATE
可用于 SQL 语句的各个部分。以下是一些示例
与
ORDER BY
一起使用SELECT k FROM t1 ORDER BY k COLLATE latin1_german2_ci;
与
AS
一起使用SELECT k COLLATE latin1_german2_ci AS k1 FROM t1 ORDER BY k1;
与
GROUP BY
一起使用SELECT k FROM t1 GROUP BY k COLLATE latin1_german2_ci;
与聚合函数一起使用
SELECT MAX(k COLLATE latin1_german2_ci) FROM t1;
与
DISTINCT
一起使用SELECT DISTINCT k COLLATE latin1_german2_ci FROM t1;
与
WHERE
一起使用SELECT * FROM t1 WHERE _latin1 'Müller' COLLATE latin1_german2_ci = k;
SELECT * FROM t1 WHERE k LIKE _latin1 'Müller' COLLATE latin1_german2_ci;
与
HAVING
一起使用SELECT k FROM t1 GROUP BY k HAVING k = _latin1 'Müller' COLLATE latin1_german2_ci;