Convert HEX column to DEC in MySQL

user2110604 picture user2110604 · Feb 26, 2013 · Viewed 22.2k times · Source

I am writing an application which will do some formatting to CSV file and uploads the table to mysql after that the program should convert a (hex) column to decimal one

The table looks like this:

col1 | col2 | hexcol | deccol

So i need to take hexcol and convert from hex2dec and put it into deccol

I tried simple SELECT UNHEX('hexcol'); but it won`t work it says this colum is not in the field list ...

Any help would be appreciated ...

Answer

Jeremy picture Jeremy · Feb 26, 2013

Try this:

SELECT CONV(hexcol, 16, 10);