使用该CONV()
方法将十六进制字符串转换为数字-
select CONV(yourColumnName,16,10) AS anyAliasName from yourTableName;
让我们首先创建一个表-
mysql> create table DemoTable -> ( -> HexString varchar(100) -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values('A'); mysql> insert into DemoTable values('F'); mysql> insert into DemoTable values('B'); mysql> insert into DemoTable values('ABC');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
输出结果
这将产生以下输出-
+-----------+ | HexString | +-----------+ | A | | F | | B | | ABC | +-----------+ 4 rows in set (0.00 sec)
以下是在MySQL中将十六进制字符串转换为数字的查询-
mysql> select CONV(HexString,16,10) AS Number from DemoTable;
输出结果
这将产生以下输出-
+--------+ | Number | +--------+ | 10 | | 15 | | 11 | | 2748 | +--------+ 4 rows in set (0.00 sec)