Oracle 5.0 Reference Manual page 2987

Table of Contents

Advertisement

mysql>
SELECT @s1 COLLATE latin1_swedish_ci = @s2;
+-------------------------------------+
| @s1 COLLATE latin1_swedish_ci = @s2 |
+-------------------------------------+
|
+-------------------------------------+
A binary string is case sensitive in comparisons. To compare the string as case insensitive, convert it to
a nonbinary string and use
mysql>
SET @s = BINARY 'MySQL';
mysql>
SELECT @s = 'mysql';
+--------------+
| @s = 'mysql' |
+--------------+
|
+--------------+
mysql>
SELECT CONVERT(@s USING latin1) COLLATE latin1_swedish_ci = 'mysql';
+--------------------------------------------------------------+
| CONVERT(@s USING latin1) COLLATE latin1_swedish_ci = 'mysql' |
+--------------------------------------------------------------+
|
+--------------------------------------------------------------+
To determine whether a value will compare as a nonbinary or binary string, use the
COLLATION()
case-insensitive collation, so comparisons are case insensitive:
mysql>
SELECT COLLATION(VERSION());
+----------------------+
| COLLATION(VERSION()) |
+----------------------+
| utf8_general_ci
+----------------------+
For binary strings, the collation value is binary, so comparisons will be case sensitive. One context in
which you will see
a general rule: string:
mysql>
SELECT COLLATION(ENCRYPT('x')), COLLATION(SHA1('x'));
+-------------------------+----------------------+
| COLLATION(ENCRYPT('x')) | COLLATION(SHA1('x')) |
+-------------------------+----------------------+
| binary
+-------------------------+----------------------+
C.5.5.2. Problems Using
The format of a
permitted. You should use this format in
statements. For example:
SELECT * FROM t1 WHERE date >= '2003-05-05';
As a convenience, MySQL automatically converts a date to a number if the date is used in a numeric
context and vice versa. MySQL also permits a "relaxed" string format when updating and in a
clause that compares a date to a DATE, DATETIME, or
means that any punctuation character may be used as the separator between parts. For example,
'2004-08-15'
separators (such as '20040815'), provided it makes sense as a date.
When you compare a DATE, TIME, DATETIME, or
>=, >, or
BETWEEN
comparison (and also for a bit more "relaxed" string checking). However, this conversion is subject to
the following exceptions:
• When you compare two columns
Query-Related Issues
COLLATE
0 |
[959]
function. This example shows that
|
is for compression and encryption functions, which return binary strings as
binary
| binary
Columns
DATE
value is 'YYYY-MM-DD'. According to standard SQL, no other format is
DATE
and
'2004#08#15'
operators, MySQL normally converts the string to an internal long integer for faster
1 |
to name a case-insensitive collation:
VERSION()
|
expressions and in the
UPDATE
TIMESTAMP
are equivalent. MySQL can also convert a string containing no
TIMESTAMP
2967
1 |
[964]
returns a string that has a
clause of
WHERE
column. "Relaxed" format
to a constant string with the <, <=, =,
SELECT
WHERE

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents