Home  >  Article  >  Database  >  Is there any function in MySQL to get the numeric code of a specific character?

Is there any function in MySQL to get the numeric code of a specific character?

WBOY
WBOYforward
2023-09-22 23:21:03955browse

Is there any function in MySQL to get the numeric code of a specific character?

The string function ASCII() in MySQL returns the ASCII numeric code for a specific character.

Syntax

ASCII(str)

Here, the parameter str of the ASCII() function is the string of the ASCII value of the first character to be retrieved.

It’s worth mentioning here that it returns the numeric code to be retrieved. Leaves the most characters, the first character of the string given as argument.

Example

mysql> SELECT ASCII('A') as 'ASCII VALUE OF CAPITAL A';
+--------------------------+
| ASCII VALUE OF CAPITAL A |
+--------------------------+
| 65                       |
+--------------------------+
1 row in set (0.00 sec)

mysql> SELECT ASCII('a') as 'ASCII VALUE OF CAPITAL a';
+--------------------------+
| ASCII VALUE OF CAPITAL a |
+--------------------------+
| 97                       |
+--------------------------+
1 row in set (0.00 sec)

mysql> SELECT ASCII('Abhay') as 'Left_most Character ASCII value';
+---------------------------------+
| Left_most Character ASCII value |
+---------------------------------+
| 65                              |
+---------------------------------+
1 row in set (0.00 sec)

The above is the detailed content of Is there any function in MySQL to get the numeric code of a specific character?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete