Name
UNHEX( )
Synopsis
UNHEX(string
)
This function converts hexadecimal
numbers to their character equivalent. It reverses the results of the
HEX( )
function. This function is available as of
Version 4.1.2 of MySQL.
SELECT ORD(UNHEX(MID('#FFFFFF', 2,2))) AS 'Red Value', ORD(UNHEX(MID('#FFFFFF', 4,2))) AS 'Green Value', ORD(UNHEX(RIGHT('#FFFFFF', 2))) AS 'Blue Value'; +-----------+-------------+------------+ | Red Value | Green Value | Blue Value | +-----------+-------------+------------+ | 255 | 255 | 255 | +-----------+-------------+------------+
This SQL statement returns the RGB
values for the color white. The ORD( )
function is
used to convert the results of UNHEX( )
to plain
text.
Get MySQL in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.