- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the similarities and differences between MySQL ORD() and ASCII() functions?
MySQL ORD() function returns the code for the leftmost character if that character is a multi-byte i.e. sequence of one or more bytes, with the help of the following formula
(1st bytecode) + (2nd bytecode * 256) + (3rd bytecode * 256^2)
On the other hand, ASCII() function returns the ASCII value of the leftmost character of a given string.
The difference between them lies on the point that whether the leftmost character is a multi-byte character or not. If it is not a multi-byte character then both ORD() and ASCII() functions return similar results. Following example will demonstrate it.
mysql> Select ORD('Tutorialspoint'); +-----------------------+ | ORD('Tutorialspoint') | +-----------------------+ | 84 | +-----------------------+ 1 row in set (0.00 sec) mysql> Select ASCII('Tutorialspoint'); +-------------------------+ | ASCII('Tutorialspoint') | +-------------------------+ | 84 | +-------------------------+ 1 row in set (0.00 sec)
Advertisements