Name

HEX( )

Synopsis

HEX(number)

This function returns the hexadecimal value of number.

SELECT CONCAT('#', HEX(255), HEX(255), HEX(255))
       AS White;
+---------+
| White   |
+---------+
| #FFFFFF |
+---------+

This SQL statement converts the RGB (red, green, and blue) values given to their hexadecimal equivalent for the color white.

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.