开发者

cut matched pattern from column

开发者 https://www.devze.com 2023-03-03 16:06 出处:网络
i have bunch of rows containing http://www.do开发者_开发知识库mainname.com i need to update those so http:// part is gone

i have bunch of rows containing http://www.do开发者_开发知识库mainname.com i need to update those so http:// part is gone how to do this elegantly within one query execution??

e.g. table 'video', column in question 'url'


try

UPDATE `video` SET `url` = REPLACE(`url`,"http://","")


First execute the query below to ensure that the output is as expected

SELECT SUBSTRING(url,  8) as url FROM video;

If you are satisfied execute

UPDATE video SET url = SUBSTRING(url,  8);
0

精彩评论

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

关注公众号