MySQL内置函数-单行函数(进制换算函数)

进制换算

conv(n,from_base,to_base)

例如:
 
mysql> select conv("a",16,2);  --意思就是 将16进制的‘a’转换成2进制的

+----------------+
| conv("a",16,2) |
+----------------+
| 1010           |
+----------------+
1 row in set (0.00 sec)
mysql> select ascii(‘a‘);
+------------+
| ascii(‘a‘) |
+------------+
|         97 |
+------------+
1 row in set (0.00 sec)

mysql> select bin(10);
+---------+
| bin(10) |
+---------+
| 1010    |
+---------+
1 row in set (0.00 sec)

mysql> select oct(10);
+---------+
| oct(10) |
+---------+
| 12      |
+---------+
1 row in set (0.00 sec)

mysql> select hex(10);
+---------+
| hex(10) |
+---------+
| A       |
+---------+
1 row in set (0.00 sec)

char(n,...) 返回由参数n,...对应的ascii代码字符组成的一个字串(参数是n,...是数字序列,null值被跳过

mysql> select char(77,121,83,81,‘76‘);
+-------------------------+
| char(77,121,83,81,‘76‘) |
+-------------------------+
| MySQL                   |
+-------------------------+
1 row in set (0.00 sec)

mysql> select char(77,77.5,‘77.3‘);
+----------------------+
| char(77,77.5,‘77.3‘) |
+----------------------+
| MNM                  |
+----------------------+
1 row in set, 1 warning (0.00 sec)

MySQL内置函数-单行函数(进制换算函数)

上一篇:mybatis-plus 控制台打印sql,配置文件xml需注释掉,否则会冲突


下一篇:MySQL内置函数-版本、用户等函数