常用的内置函数,常用select\
- 字符串函数
- contat('' , '', .....) //连接字符串
select concat(name, ' age is ', age) from persons;
- insert(a, 2, 3, insert) //将字符a的第2个位置开始,3个字符替换为insert
mysql> select name, insert(name, 2, 3, 'hello') from persons;
+------------+-----------------------------+
| name | insert(name, 2, 3, 'hello') |
+------------+-----------------------------+
| kaily_zhou | khelloy_zhou |
| zhangsan | zhellogsan |
+------------+-----------------------------+
2 rows in set (0.00 sec)
- upper() / lower()大小写转换
select upper("hello");
select lower("HELLO");
- left('', 2) /right('', 3)
select left('hello', 2), right('hello', 3); //返回字符串的左边右边几个字符
- lpad(name, 10, pa), rpad(name, 10, pa); //为了凑够10个字符,在字符串左边或者右边添加pa
mysql> select name, lpad(name, 20, '#'), rpad(name, 20, '@') from persons;
+------------+----------------------+----------------------+
| name | lpad(name, 20, '#') | rpad(name, 20, '@') |
+------------+----------------------+----------------------+
| kaily_zhou | ##########kaily_zhou | kaily_zhou@@@@@@@@@@ |
| zhangsan | ############zhangsan | zhangsan@@@@@@@@@@@@ |
+------------+----------------------+----------------------+
2 rows in set (0.00 sec)
- 数值函数
- 日期函数