MySQL 内置函数之字符串函数
MySQL 大约 825 字字符串函数
- 查看字符的
ascii
码值ascii(str)
,str
是空串时返回0
select ascii('a');
- 查看
ascii
码值对应的字符char
(数字)
select char(97);
- 拼接字符串
concat(str1,str2...)
select concat(12,34,'ab');
- 包含字符个数
length(str)
select length('abc');
- 截取字符串
left(str,len
)返回字符串str
的左端len
个字符right(str,len)
返回字符串str
的右端len
个字符substring(str,pos,len)
返回字符串str
的位置pos
起len
个字符
select substring('abc123',2,3);
- 去除空格
ltrim(str)
返回删除了左空格的字符串str
rtrim(str)
返回删除了右空格的字符串str
trim
([方向 remstr from str)返回从某侧删除remstr
后的字符串str
,方向词包括both
、leading
、trailing
,表示两侧、左、右
select trim(' bar ');
select trim(leading 'x' FROM 'xxxbarxxx');
select trim(both 'x' FROM 'xxxbarxxx');
select trim(trailing 'x' FROM 'xxxbarxxx');
- 返回由
n
个空格字符组成的一个字符串space(n)
select space(10);
- 替换字符串
replace(str,from_str,to_str)
select replace('abc123','123','def');
- 大小写转换,函数如下
lower(str)
upper(str)
select lower('aBcD');
阅读 2320 · 发布于 2019-04-07
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
Redis 执行 Lua 脚本抛出 StatusOutput does not support set(long) 异常阅读 9749
-
wget ERROR The certificate was signed using an insecure algorithm阅读 2556
-
MySQL ERROR 1193 (HY000): Unknown system variable 'validate_password_policy'阅读 6702
-
IDEA 开发中常用的快捷键阅读 1359
-
Docker CMD ENTRYPOINT 区别阅读 1214
-
Go 命令之 go build阅读 1492
-
Linux 添加 iptables 防火墙规则阅读 2429
-
Java 中的强引用、软引用、弱引用、虚引用、引用队列阅读 1658
-
Linux 之校准服务器时间阅读 2902
-
软考-系统架构设计师:NoSQL阅读 2130