Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Convert hex string to number in MySQL?
Use the CONV() method to convert hex string to number −
select CONV(yourColumnName,16,10) AS anyAliasName from yourTableName;
Let us first create a table −
mysql> create table DemoTable -> ( -> HexString varchar(100) -> ); Query OK, 0 rows affected (0.82 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('A');
Query OK, 1 row affected (0.28 sec)
mysql> insert into DemoTable values('F');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values('B');
Query OK, 1 row affected (0.55 sec)
mysql> insert into DemoTable values('ABC');
Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
This will produce the following output −
+-----------+ | HexString | +-----------+ | A | | F | | B | | ABC | +-----------+ 4 rows in set (0.00 sec)
Following is the query to convert hex string to number in MySQL −
mysql> select CONV(HexString,16,10) AS Number from DemoTable;
Output
This will produce the following output −
+--------+ | Number | +--------+ | 10 | | 15 | | 11 | | 2748 | +--------+ 4 rows in set (0.00 sec)
Advertisements
