left(str, length)
说明:left(被截取字段,截取长度)
例:select left(content,200) as abstract from my_content_t
right(str, length)
说明:right(被截取字段,截取长度)
例:select right(content,200) as abstract from my_content_t
substring(str, pos)
substring(str, pos, length)
说明:substring(被截取字段,从第几位开始截取)
substring(被截取字段,从第几位开始截取,截取长度)
例:select substring(content,5) as abstract from my_content_t
select substring(content,5,200) as abstract from my_content_t
(注:如果位数是负数 如-5 则是从后倒数位数,到字符串结束或截取的长度)
substr(string, start_point, length【可选参数】)
string:从哪个内容中截取,可以是数值或字符串。
start_point:从哪个字符开始截取(1开始,而不是0开始)
length:截取几个字符(空格也算一个字符)
select device_id, substr(blog_url,11,length(blog_url)-10) as user_nam
substring_index(str,delim,count)
说明:substring_index(被截取字段,关键字,关键字出现的次数)
例:select substring_index(“blog.jb51.net”,“。”,2) as abstract from my_content_t
结果:blog.jb51
(注:如果关键字出现的次数是负数 如-2 则是从后倒数,到字符串结束)
replace(string, '被替换部分','替换后的结果')
select replace(blog_url,‘http:/url/’,‘’) as user_name
trim('被删除字段' from 列名)
select trim(‘http:/url/’ from blog_url) as user_name
select trim(’ abc ') as rs;
输出结果为:abc
select trim(‘http:/url/’ from ‘http:/url/blog.html’) as rs;
输出结果为:blog.html
❤️希望对您有帮助,您的支持是我创作最大的动力!