的反向功能CHAR()
ISASCII()
或ORD()
在MySQL。此处,ASCII()
返回ORD()
最左边字符的数值,而返回参数最左边字符的字符代码
让我们首先创建一个表-
mysql> create table DemoTable ( Value int, Value1 char(1), Value2 char(1) );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values(65,'A','A'); mysql> insert into DemoTable values(97,'a','a');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+-------+--------+--------+ | Value | Value1 | Value2 | +-------+--------+--------+ | 65 | A | A | | 97 | a | a | +-------+--------+--------+ 2 rows in set (0.00 sec)
现在让我们实现ASCII和ORD-
mysql> select char(Value),ASCII(Value1),ORD(Value2) from DemoTable;
这将产生以下输出-
+-------------+---------------+-------------+ | char(Value) | ASCII(Value1) | ORD(Value2) | +-------------+---------------+-------------+ | A | 65 | 65 | | a | 97 | 97 | +-------------+---------------+-------------+ 2 rows in set (0.03 sec)