天天看点

.net mvc actionresult 返回字符串_mysql 字符串定位、字符串截取

.net mvc actionresult 返回字符串_mysql 字符串定位、字符串截取
mysql 字符串定位、字符串截取

作者: 蓝精灵lx

https://blog.csdn.net/liuxiao723846/article/details/50341821

1、locate函数可以实现类似indexof的功能,locate(substr,str)返回substr子串在字符串str中的位置。

2、substring函数,截取字符串:

substring(str, pos)

substring(str, pos, length)

说明:substring(被截取字段,从第几位开始截取)

substring(被截取字段,从第几位开始截取,截取长度)

3、按关键字截取字符串 :

substring_index(str,delim,count)

说明:substring_index(被截取字段,关键字,关键字出现的次数)

例:select substring_index("http://blog.jb51.net",".",2) as abstract from my_content_t

结果:blog.jb51

继续阅读