MYSQL: Convert hex string to integer

Posted on May 7th, 2010 by whinger. Filed under Tech, Web Development.


So there’s a few places on the web asking how to do this; while it’s easy to do

SELECT x'1fb5';

if you have the hex string stored in a field you can’t do that.

The answer is to use CONV()

ie

SELECT CONV(myhexfield, 16, 10);

It’s that simple.

Tags:



Trackback URI | Comments RSS

Leave a Reply


Blogroll

Categories