查找字符位置語句:instr
select instr(t.f_fylxmc,'-') from w_w_fm_day_cost t
返回結果是0,索引從0開始
截取字符串位置語句:substr
select substr(t.f_fylxmc, instr(t.f_fylxmc,'-')+1,100) from w_w_fm_day_cost t
目的是截取f_fylxmc字段中從 - 之後的字符,因爲不包括-符號,所以查詢位置需要+1,
結束位置之所以寫爲100是因爲不知道字符串最長是多少,該方法適用於批量修改截取。
批量更新語句:
update w_w_fm_day_cost c set c.f_fylxmc=substr(c.f_fylxmc,instr(c.f_fylxmc,'-')+1,100)