W3Cschool
恭喜您成為首批注冊用戶
獲得88經驗值獎勵
1、從左開始截取字符串
select left(content,200) as abstract from my_content_t
2、從右開始截取字符串 select right(content,200) as abstract from my_content_t
3、截取字符串 例:
select substring(content,5) as abstract from my_content_t
select substring(content,5,200) as abstract from my_content_t
(注:如果位數是負數 如-5 則是從后倒數位數,到字符串結束或截取的長度) 例:
select substring_index("hgci.cn",".",2) as abstract from wiki_user
結果:www.w3cschool函數簡介:
SUBSTRING(str,pos) , SUBSTRING(str FROM pos) SUBSTRING(str,pos,len) , SUBSTRING(str FROM pos FOR len)
不帶有l(wèi)en 參數的格式從字符串str返回一個子字符串,起始于位置 pos。帶有l(wèi)en參數的格式從字符串str返回一個長度同len字符相同的子字符串,起始于位置 pos。 使用 FROM的格式為標準 SQL 語法。也可能對pos使用一個負值。假若這樣,則子字符串的位置起始于字符串結尾的pos 字符,而不是字符串的開頭位置。在以下格式的函數中可以對pos 使用一個負值。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯系方式:
更多建議: