3 messages in com.mysql.lists.mysqlRe: Converting string hex column to i...
FromSent OnAttachments
Dušan Pavlica28 Jun 2006 04:53 
Wolfram Kraus28 Jun 2006 05:48 
Dušan Pavlica28 Jun 2006 06:24 
Subject:Re: Converting string hex column to integer
From:Wolfram Kraus (kra@hagen-partner.de)
Date:06/28/2006 05:48:33 AM
List:com.mysql.lists.mysql

On 28.06.2006 13:54, Dušan Pavlica wrote:

Hello, I have column of type char(2) containing hex numbers (e.g. "0A", "FF", ...) and I cannot find correct function which could convert those hex numbers to integers so I can perform futher calculations. I experimented with HEX(), CAST(), CONVERT() but I wasn't succesfull.

Thanks in advance, Dusan

Use conv:

mysql> select conv('11', 16, 10); +--------------------+ | conv('11', 16, 10) | +--------------------+ | 17 | +--------------------+ 1 row in set (0.01 sec)

mysql> select conv('0a', 16, 10) + conv('a0', 16, 10); +-----------------------------------------+ | conv('0a', 16, 10) + conv('a0', 16, 10) | +-----------------------------------------+ | 170 | +-----------------------------------------+

See: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html

HTH, Wolfram