Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2023-09-22 23:21:03
forward
942 people have browsed it

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)
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!