开发者

SQL Update - Deleting last 45 char of a string

开发者 https://www.devze.com 2023-03-24 13:46 出处:网络
I want to delete last 45 开发者_JAVA技巧char of an attribute in all rows. What can I do ? UPDATE tablename

I want to delete last 45 开发者_JAVA技巧char of an attribute in all rows. What can I do ?


UPDATE tablename
   SET fieldname = IF(LENGTH(fieldname) > 45,
                      SUBSTR(fieldname, 1, LENGTH(fieldname) - 45),
                      fieldname)


try this :

update table
set column = right(column , 44) 
0

精彩评论

暂无评论...
验证码 换一张
取 消