
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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)
- Related Articles
- How to Convert Hex String to Hex Number in C#?
- Convert Integer to Hex String in Java
- Convert byte Array to Hex String in Java
- Convert Hex String to byte Array in Java
- How to convert Int to Hex String in Kotlin?
- Python program to convert hex string to decimal
- How to convert hex string into int in Python?
- Convert an integer to a hex string in C++
- How to convert hex string to byte Array in Java?
- How to convert a byte array to hex string in Java?
- How to convert a byte array to a hex string in Java?
- How to convert a color integer to a hex String in Android?
- How to Convert Decimal Number to Binary/Octal/Hex Number or Vice Versa in Excel?
- MySQL query to convert a string into a month (Number)?
- How to Convert Hex to Binary in Excel?

Advertisements