![background image](http://html1.mh-extra.com/html/oracle/5-0/5-0_reference-manual_1646196801.webp)
Collation Issues
781
10.1.7.2. Using
COLLATE
in SQL Statements
With the
COLLATE
clause, you can override whatever the default collation is for a comparison.
COLLATE
may be used in various parts of SQL statements. Here are some examples:
• With
ORDER BY
:
SELECT k
FROM t1
ORDER BY k COLLATE latin1_german2_ci;
• With
AS
:
SELECT k COLLATE latin1_german2_ci AS k1
FROM t1
ORDER BY k1;
• With
GROUP BY
:
SELECT k
FROM t1
GROUP BY k COLLATE latin1_german2_ci;
• With aggregate functions:
SELECT MAX(k COLLATE latin1_german2_ci)
FROM t1;
• With
DISTINCT
:
SELECT DISTINCT k COLLATE latin1_german2_ci
FROM t1;
• With
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;
• With
HAVING
:
SELECT k
FROM t1
GROUP BY k
HAVING k = _latin1 'Müller' COLLATE latin1_german2_ci;
10.1.7.3.
COLLATE
Clause Precedence
The
COLLATE
clause has high precedence (higher than
||
[881]
), so the following two expressions
are equivalent:
x || y COLLATE z
x || (y COLLATE z)
10.1.7.4. Collations Must Be for the Right Character Set
Each character set has one or more collations, but each collation is associated with one and only one
character set. Therefore, the following statement causes an error message because the
latin2_bin
collation is not legal with the
latin1
character set:
mysql>
SELECT _latin1 'x' COLLATE latin2_bin;
ERROR 1253 (42000): COLLATION 'latin2_bin' is not valid
for CHARACTER SET 'latin1'
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...