Name
COLLATE — Associate a specific collation to an expression
Syntax
Description
The COLLATE
operator associates a specific
collation with an expression. The COLLATE
operator does not alter the value of
the expression, but it does change how equality and ordering are
tested in the enclosing expression.
If two text expressions are involved in an equality or order test, the collation is determined with the following rules:
If the lefthand (first) expression has an explicit collation, that is used.
If the righthand (second) expression has an explicit collation, that is used.
If the lefthand (first) expression is a direct reference to a column with a collation, the column collation is used.
If the righthand (second) expression is a direct reference to a column with a collation, the column collation is used.
The default
BINARY
collation is used.
For example:
'abc' == 'ABC' => 0 (false) 'abc' COLLATE NOCASE == 'ABC' => 1 (true) 'abc' == 'ABC' COLLATE NOCASE => 1 (true) 'abc' COLLATE NOCASE == 'ABC' COLLATE BINARY => 1 (true) 'abc' COLLATE BINARY == 'ABC' COLLATE NOCASE => 0 (false)
For more information on collations, see Collation Functions.
See Also
CREATE TABLE, sqlite3_create_collation() [C API, Ap G]
Get Using SQLite now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.