我有一个像这样的表:
| 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'
我先手动更新链接,但还剩下很多。我自己无法全部更新。
有什么想法吗?
最佳答案
您在表列表中将其称为“Field”,但在 SQL 中将其称为“link”,所以我将使用“Field”
update table
set
Field = replace(Field, 'dev.site.com', 'site.com/resources')
where
Field rlike '^dev.site.com'
关于mysql - 使用正则表达式在 MySQL 中编辑整列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16350906/