In MySQL, how can we get the number code of a particular character?


With the help of MySQL string function ASCII(), we can get the number code of a particular character. Its syntax is ASCII(str) where, str, the argument of ASCII() function, is the string whose ASCII value of the first character to be retrieved.

It will return the number code the left the most character i.e. first character of the string given as argument.

Example

mysql> Select ASCII('T');
+------------+
| ASCII('T') |
+------------+
|         84 |
+------------+
1 row in set (0.01 sec)

mysql> Select ASCII('t');
+------------+
| ASCII('t') |
+------------+
|        116 |
+------------+
1 row in set (0.00 sec)

mysql> Select ASCII('Tutorialspoint');
+-------------------------+
| ASCII('Tutorialspoint') |
+-------------------------+
|                      84 |
+-------------------------+
1 row in set (0.00 sec)

mysql> Select ASCII('tutorialspoint');
+-------------------------+
| ASCII('tutorialspoint') |
+-------------------------+
|                     116 |
+-------------------------+
1 row in set (0.00 sec)

Updated on: 07-Feb-2020

198 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements