:: DEVELOPER ZONE
Every character string literal has a character set and a collation, which may not be null.
A character string literal may have an optional character set
introducer and COLLATE clause:
[_charset_name]'string' [COLLATEcollation_name]
Examples:
SELECT 'string'; SELECT _latin1'string'; SELECT _latin1'string' COLLATE latin1_danish_ci;
For the simple statement SELECT
', the string has the
character set and collation defined by the
string'character_set_connection and
collation_connection system variables.
The _
expression is formally called an introducer. It
tells the parser, ``the string that is about to follow is in
character set charset_nameX.'' Because this has confused
people in the past, we emphasize that an introducer does not cause
any conversion, it is strictly a signal that does not change the
string's value. An introducer is also legal before standard hex
literal and numeric hex literal notation
(x' and
literal'0x), and before
nnnn? (parameter substitution when using prepared
statements within a programming language interface).
Examples:
SELECT _latin1 x'AABBCC'; SELECT _latin1 0xAABBCC; SELECT _latin1 ?;
MySQL determines a literal's character set and collation thus:
If both _X and COLLATE
were specified, then
character set YX and collation
Y
If _X is specified but
COLLATE is not specified, then character set
X and its default collation
Otherwise, the character set and collation given by the
character_set_connection and
collation_connection system variables
Examples:
A string with latin1 character set and
latin1_german1_ci collation:
SELECT _latin1'Müller' COLLATE latin1_german1_ci;
A string with latin1 character set and its
default collation (that is, latin1_swedish_ci):
SELECT _latin1'Müller';
A string with the connection default character set and collation:
SELECT 'Müller';
Character set introducers and the COLLATE clause
are implemented according to standard SQL specifications.
© 1995-2005 MySQL AB. All rights reserved.

User Comments
Warning: query failed: Unknown column 'user.firstname' in 'field list' in /data0/sites/live/web-main/lib/mysql-cxn.php on line 69
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /data0/sites/live/web-main/lib/docbook.php on line 245
Add your own comment.