MySQL学习----MySQL函数(一)----10MySQL字符串函数

来源:互联网 发布:云计算 云服务 编辑:程序博客网 时间:2024/06/10 03:40
-- MySQL字符串函数


-- 字符串长度
select length("hello");


-- 变成小写
select lcase("Hello");
select lower("Hello");


-- -- 变成大写
select ucase("Hello");
select upper("Hello");


-- 字符串比大小(比的是首字母在字母表中的顺序)
select strcmp('hello','yes');
select strcmp('zello','yes');
select strcmp('yes','yes');


-- 字符串定位函数
select position('yes' in 'yesllo');


-- y替换成h
select replace('yes','y','h');


-- 插入函数
select insert ('yes wrold',2,3,'kkk');


-- 字符串合并
select concat('hello','world');


-- 字符串合并,加间隔符
select concat_ws(';','hello','world');


-- 取左边字符
select left('helloworld',3);


-- 取右边字符
select right('helloworld',3);


-- 左边填充
select lpad('helloworld', 15, 'x');


-- 右边填充
select rpad('helloworld', 15, 'x');


-- 去左空格函数
select ltrim('         helloworld');


-- 去左右空格函数
select trim('         helloworld      ');


-- 截取字符串
select substring('macket',2,3);


-- -- 截取字符的ASCII
select ascii('a');























































0 0
原创粉丝点击