方法:1、利用right函數,語法為“update 表名 set 指定字段 = right(指定字段, length(指定字段)-1)…”;2、利用substring函數,語法為“select substring(指定字段,2)..”。
本教程操作環境:windows10系統、mysql8.0.22版本、Dell G3電腦。
mysql怎么去掉第一個字符
MySQL 字符串截取相關函數:
1、從右開始截取字符串
right(str,?length)
說明:right(被截取字段,截取長度)
例:
select?right(content,200)?as?abstract?from?my_content_t
去除指定字段的第一個字符”
update?表名?set?指定字段?=?right(指定字段,?length(指定字段)-1)?WHERE?指定字段?like?'"%';
2、截取字符串
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 則是從后倒數位數,到字符串結束或截取的長度)
推薦學習:mysql視頻教程
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END
喜歡就支持一下吧
相關推薦