– 字符串函数
– 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');