MySQL Tutorial/String Functions/UNHEX

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

HEX(UNHEX("1267"));

mysql>
mysql>
mysql> SELECT HEX(UNHEX("1267"));
+--------------------+
| HEX(UNHEX("1267")) |
+--------------------+
| 1267               |
+--------------------+
1 row in set (0.02 sec)


UNHEX("GG");

mysql>
mysql>
mysql> SELECT UNHEX("GG");
+-------------+
| UNHEX("GG") |
+-------------+
| NULL        |
+-------------+
1 row in set (0.00 sec)
mysql>


UNHEX(HEX("string"));

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


UNHEX(str) interprets each pair of hexadecimal digits as a number and converts it to the character

The resulting characters are returned as a binary string.

Performs the inverse operation of HEX(str).



mysql> SELECT UNHEX("4D7953514C");
+---------------------+
| UNHEX("4D7953514C") |
+---------------------+
| MySQL               |
+---------------------+
1 row in set (0.00 sec)
mysql>