ASCII()
MySQL中的字符串函数返回特定字符的ASCII数字代码。
ASCII(str)
在这里,str(ASCII()
函数的参数)是要检索的第一个字符的ASCII值的字符串。
在这里需要提及的是,它将返回最左边的数字代码,即作为参数给出的字符串的第一个字符。
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)