What MySQL returns if I provide a non-hexadecimal number as an argument to UNHEX() function?


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: 20-Jun-2020

82 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements