使用正则表达式使用MySQL编辑整个列
我有一张这样的桌子:使用正则表达式使用MySQL编辑整个列,mysql,sql,regex,Mysql,Sql,Regex,我有一张这样的桌子: | link | ---------- http://dev.example.com/images/image1.png http://dev.example.com/images/image2.png http://dev.example.com/images/image3.png http://dev.example.com/images/image4.png 但是,我需要更改它,使其包含: | link | ---------- http://example.c
| link |
----------
http://dev.example.com/images/image1.png
http://dev.example.com/images/image2.png
http://dev.example.com/images/image3.png
http://dev.example.com/images/image4.png
但是,我需要更改它,使其包含:
| link |
----------
http://example.com/resources/images/image1.png
http://example.com/resources/images/image2.png
http://example.com/resources/images/image3.png
http://example.com/resources/images/image4.png
有很多条目需要更改。更新所有条目的好方法是什么
现在我用这个来查找条目:
SELECT column
FROM table
WHERE link REGEXP '^dev'
我是手动更新的链接第一,但有这么多的左。我不能自己全部更新
有什么想法吗?在表列表中称之为“字段”,但在SQL中称之为“链接”,所以我将使用“字段”
update table
set
Field = replace(Field, 'dev.site.com', 'site.com/resources')
where
Field rlike '^dev.site.com'