mysql中的字符串函数

– 字符串函数
– 1.获取字符串

select char_length('hello'); -- 5

– length 取长度,返回的单位是字节

select length('hellow') -- 5\
select length('你好吗'); -- 9

– 2.字符串合并

select concat('hellow','world');

– 3.指定分隔符进行字符串的合并

select concat_ws('_','hellow','world');

– 4.返回字符串在列表中的位置

select field('aaa','aaa','bbb','ccc');

– 5.去除字符串左右边的空格

select ltrim('     aaaa');
select rtrim('   aaa    ');
select trim('   aaa    '); -- 去除两端空格

– 6.字符串的截取:

select mid('helloworld',2,3); -- 从第二个字符开始截取,截取长度为3

– 7.获取字符串A在字符串中的位置

select position('abc' in 'hellowabcworld');

– 8.字符串的替换

select replace('helloaaaworld','aaa','bbb');

– 9.字符串的翻转

select reverse('hello');

– 10.返回字符串的后几个字符

select right('hello',3); -- 返回后面三个字符

– 11.字符串的比较

select strcmp('hello','world');

– 12.字符串的截取

select substr('hello',2,3); -- 从第二个字符截取三个
select substring('hello',2,3);

– 13.将小写转大写

select ucase('helloWorld');
select upper('helloWorld');

– 将大写转为小写

select lcase('helloWorld');
select lower('helloWorld');
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值