Allen 2020-05-16 23:14:24 10471 0 0 0 0
mysql,字符串,函数,Mysql字符串函数--获取字符串位置instr(str,substr)//返回字符串str中子字符串的第一个出现位置。instr("Photo|可爱毛衣灿烂","|")-->6--截取字符串s…

Mysql字符串函数

--获取字符串位置

instr(str,substr) //返回字符串 str 中子字符串的第一个出现位置。

instr("Photo|可爱 毛衣 灿烂","|")  -->6

--截取字符串

substring ( expression , start , length ) 

//substring("Photo|可爱 毛衣 灿烂", 7, 20)  -->可爱 毛衣 灿烂

--替换字符中指定字符

replace('string_expression1' , 'string_expression2' , 'string_expression3')

//replace("可爱 毛衣 灿烂"," ",",") -->可爱,毛衣,灿烂'

--综合使用

select replace(substring("Photo|可爱 毛衣 灿烂",instr("Photo|可爱 毛衣 灿烂","|")+1,length("Photo|可爱 毛衣 灿烂")-instr("Photo|可爱 毛衣 灿烂","|"))," ",",")

-->可爱,毛衣,灿烂


【版權聲明】
本文爲原創,遵循CC 4.0 BY-SA版權協議!轉載時請附上原文鏈接及本聲明。
原文鏈接:https://tdlib.com/am.php?t=1dJSwZsvk27u
Tag: mysql 字符串 函数
我也要發一個   ·   返回首頁   ·   返回[Mysql]   ·   前一個   ·   下一個
歡迎評論
未登錄,
請先 [ 註冊 ] or [ 登錄 ]
(一分鍾即可完成註冊!)
返回首頁     ·   返回[Mysql]   ·   返回頂部