天天看點

.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

繼續閱讀