

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we enter numeric values as Hexadecimal (HEX) number in MySQL statement?
Following are the two approaches with the help of which we can enter numeric values as a Hexadecimal number −
By prefix ‘X’
In this approach we need to quote hexadecimal numbers within single quotes with a prefix of X. Then HEX number string will be automatically converted into a number based on the expression context.
Example
mysql> Select X'5152545678'+ 10; +-------------------+ | X'5152545678'+ 10 | +-------------------+ | 349273609858 | +-------------------+ 1 row in set (0.00 sec)
By prefix 0x
In this approach, we need to write hexadecimal numbers without any quotes with a prefix of 0x. Then HEX number string will be automatically converted into a numerical value based on the expression context.
Example
mysql> Select 0x5152545678+10; +-----------------+ | 0x5152545678+10 | +-----------------+ | 349273609858 | +-----------------+ 1 row in set (0.00 sec)
- Related Questions & Answers
- How can we enter characters as Hexadecimal (HEX) number in MySQL statement?
- How can we enter numerical values as a BINARY number in MySQL statement?
- How can we enter characters as a BINARY number in MySQL statement?
- How can we enter BOOLEAN values in MySQL statement?
- How can we specify default values in MySQL INSERT statement?
- How can we convert TIME and DATETIME values to numeric form in MySQL?
- Can we return query results in same order as the values in MySQL `IN(…)` statement?
- How can we update any value in MySQL view as we can update the values in MySQL table?
- In MySQL, how we can write Multiple-line statement?
- How can we escape special characters in MySQL statement?
- How can we use SIGNAL statement with MySQL triggers?
- How can we update columns values on multiple rows with a single MySQL UPDATE statement?
- How can we use MySQL SELECT statement to count number of rows in a table?
- How can we run a MySQL statement without termination semicolon?
- How can we use a MySQL subquery with INSERT statement?
Advertisements