MySQL Tutorial/String Functions/HEX — различия между версиями

Материал из SQL эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 13:44, 26 мая 2010

HEX("abc");

mysql>
mysql>
mysql> SELECT HEX("abc");
+------------+
| HEX("abc") |
+------------+
| 616263     |
+------------+
1 row in set (0.00 sec)
mysql>


HEX(N_or_S)

If N_or_S is a number, returns a string representation of the hexadecimal value of N.

If N_or_S is a string, returns a hexadecimal string representation of N_or_S where each character in N_or_S is converted to two hexadecimal digits.



mysql>
mysql> SELECT HEX(255);
+----------+
| HEX(255) |
+----------+
| FF       |
+----------+
1 row in set (0.00 sec)
mysql>


SELECT HEX(CHAR(1,0,0)), HEX(CHAR(256*256));

mysql>
mysql>
mysql> SELECT HEX(CHAR(1,0,0)), HEX(CHAR(256*256));
+------------------+--------------------+
| HEX(CHAR(1,0,0)) | HEX(CHAR(256*256)) |
+------------------+--------------------+
| 010000           | 010000             |
+------------------+--------------------+
1 row in set (0.02 sec)
mysql>
mysql>


SELECT HEX(CHAR(1,0)), HEX(CHAR(256));

mysql>
mysql>
mysql> SELECT HEX(CHAR(1,0)), HEX(CHAR(256));
+----------------+----------------+
| HEX(CHAR(1,0)) | HEX(CHAR(256)) |
+----------------+----------------+
| 0100           | 0100           |
+----------------+----------------+
1 row in set (0.00 sec)
mysql>