(mysql.info.gz) Hexadecimal values
Info Catalog
(mysql.info.gz) Number syntax
(mysql.info.gz) Literals
(mysql.info.gz) Boolean values
9.1.3 Hexadecimal Values
------------------------
MySQL supports hexadecimal values. In numeric contexts, these act like
integers (64-bit precision). In string contexts, these act like binary
strings, where each pair of hex digits is converted to a character:
mysql> SELECT x'4D7953514C';
-> 'MySQL'
mysql> SELECT 0xa+0;
-> 10
mysql> SELECT 0x5061756c;
-> 'Paul'
In MySQL 4.1 (and in MySQL 4.0 when using the `--new' option), the
default type of a hexadecimal value is a string. If you want to ensure
that the value is treated as a number, you can use `CAST(... AS
UNSIGNED)':
mysql> SELECT 0x41, CAST(0x41 AS UNSIGNED);
-> 'A', 65
The `0x' syntax is based on ODBC. Hexadecimal strings are often used by
ODBC to supply values for `BLOB' columns. The `x'hexstring'' syntax is
new in 4.0 and is based on standard SQL.
Beginning with MySQL 4.0.1, you can convert a string or a number to a
string in hexadecimal format with the `HEX()' function:
mysql> SELECT HEX('cat');
-> '636174'
mysql> SELECT 0x636174;
-> 'cat'
Info Catalog
(mysql.info.gz) Number syntax
(mysql.info.gz) Literals
(mysql.info.gz) Boolean values
automatically generated byinfo2html