MySQL UNHEX Function with Non-Hexadecimal Argument



MySQL returns NULL if we provide any non-hexadecimal number as an argument to UNHEX() function. Following example will demonstrate it.

Example

mysql> Select UNHEX('ANK96598');
+-------------------+
| UNHEX('ANK96598') |
+-------------------+
| NULL              |
+-------------------+
1 row in set (0.00 sec)

As we know that the valid hexadecimal digits are between ‘0…9’, ‘A…F’ or ‘a…f’ hence the above query returns NULL.

Updated on: 2020-06-20T11:58:11+05:30

148 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements