开发者

replacing value of a column(unknown length) with substring

开发者 https://www.devze.com 2023-03-19 18:42 出处:网络
How can I replace the value(unknown length) of a column in mySQL workbench with a substring that exists in that column?

How can I replace the value(unknown length) of a column in mySQL workbench with a substring that exists in that column?

For ex:

If I have the value of a column like "ABC.123.Chrome/123", how do I replace this for all rows with just "Chrome/123"? I want to replace value in that string of unknown length with everything that comes after C开发者_运维知识库hrome only.


This should work if you want to include Chrome:

UPDATE MyTable 
SET ColumnName = SUBSTRING(ColumnName,LOCATE('Chrome'))
WHERE ColumnName LIKE '%Chrome%'
0

精彩评论

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

关注公众号