MySql 替換某一個字段的值


update  table  set  name  replace ( name , 'name_' , '' where  name  like  'name_%' ; --替換
 

replace(name,'name_','')

把name中出現'name_'的全部替換為''

 

update  table  set  name  = substr( name ,6)  where  name  like  'name_%' --截取
 

mysql中的substr()函數

用法:

substr(string string,num start,num length);

string為字符串;

start為起始位置;

length為長度。

mysql中的start是從1開始的

substr(name,6) 從第六位開始到最后一位


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM