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.
'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.