借助MySQL字符串函数ASCII()
,我们可以获得特定字符的数字代码。它的语法为ASCII(str),其中函数的参数strASCII()
是要检索的第一个字符的ASCII值的字符串。
它将返回最左边的数字代码,即作为参数给出的字符串的第一个字符。
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('Nhooo'); +-------------------------+ | ASCII('Nhooo') | +-------------------------+ | 84 | +-------------------------+ 1 row in set (0.00 sec) mysql> Select ASCII('nhooo'); +-------------------------+ | ASCII('nhooo') | +-------------------------+ | 116 | +-------------------------+ 1 row in set (0.00 sec)