Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert HEX column to DEC in MySQL

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 ...

like image 478
user2110604 Avatar asked Feb 26 '13 09:02

user2110604


2 Answers

Try this:

SELECT CONV(hexcol, 16, 10);
like image 198
Jeremy Avatar answered Sep 23 '22 22:09

Jeremy


You can use CONV()

Check Similar question on stack overflow and Conv function reference & examples

like image 36
IamFraz Avatar answered Sep 24 '22 22:09

IamFraz