# 10.8.1 在 SQL 语句中使用 COLLATE

随着整理子句,您可以覆盖任何默认排序规则进行比较。整理可用于 SQL 语句的各个部分。这里有些例子:

  • 订购方式

    SELECT k
    FROM t1
    ORDER BY k COLLATE latin1_german2_ci;
    
  • 作为

    SELECT k COLLATE latin1_german2_ci AS k1
    FROM t1
    ORDER BY k1;
    
  • 通过...分组

    SELECT k
    FROM t1
    GROUP BY k COLLATE latin1_german2_ci;
    
  • 使用聚合函数:

    SELECT MAX(k COLLATE latin1_german2_ci)
    FROM t1;
    
  • 清楚的

    SELECT DISTINCT k COLLATE latin1_german2_ci
    FROM t1;
    
  • 在哪里

         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;
    
  • 拥有

    SELECT k
    FROM t1
    GROUP BY k
    HAVING k = _latin1 'Müller' COLLATE latin1_german2_ci;