+
+ A collation expression
+
+
+
A scalar subquery
- clause">
-
COLLATE Clause
+ exprs">
+
Collation Expressions
- The two typical uses of the COLLATE clause are
+ The two common uses of the COLLATE clause are
overriding the sort order in an ORDER BY> clause, for
example:
and overriding the collation of a function or operator call that
has locale-sensitive results, for example:
-SELECT * FROM tbl WHERE a > 'foo' COLLATE "C";
+SELECT * FROM tbl WHERE a > 'foo' COLLATE "C";
+
+ Note that in the latter case the COLLATE> clause is
+ attached to an input argument of the operator we wish to affect.
+ It doesn't matter which argument of the operator or function call the
+ COLLATE> clause is attached to, because the collation that is
+ applied by the operator or function is derived by considering all
+ arguments, and an explicit COLLATE> clause will override the
+ collations of all other arguments. (Attaching non-matching
+ COLLATE> clauses to more than one argument, however, is an
+ error. For more details see .)
+ Thus, this gives the same result as the previous example:
+SELECT * FROM tbl WHERE a COLLATE "C" > 'foo';
+
+ But this is an error:
+SELECT * FROM tbl WHERE (a > 'foo') COLLATE "C";
- In the latter case it doesn't matter which argument of the
- operator of function call the COLLATE> clause is
- attached to, because the collation that is applied by the operator
- or function is derived from all arguments, and
- the COLLATE> clause will override the collations of all
- other arguments. Attaching nonmatching COLLATE>
- clauses to more than one argument, however, is an error.
+ because it attempts to apply a collation to the result of the
+ >> operator, which is of the non-collatable data type
+ boolean>.