[英]How can I change the domain of a URL within a varchar column?
I have a database structure where one of my columns (innerLink) has a URL within it. 我有一个数据库结构,其中我的一列(innerLink)内有一个URL。
So that innerLink column will have a URL structured as follows http://www.123456.com/forums/showthread.php?t=123456 这样,innerLink列将具有如下结构的URL: http ://www.123456.com/forums/showthread.php?t=123456
I wanted to change the http://www.123456.com
to a wholly different URL --> http://789.123.com
without affecting the rest of the URL structure (ie. /forums/showthread.php?t=123456
) 我想将
http://www.123456.com
更改为完全不同的URL-> http://789.123.com
而不影响其余URL结构(即/forums/showthread.php?t=123456
)
I need this change to hit every URL in that column that is on the 123456 domain. 我需要此更改才能击中123456域上该列中的每个URL。 I have other URLs such as cnn.com or msnbc.com so I dont want those affected.
我还有其他网址,例如cnn.com或msnbc.com,所以我不希望这些网址受到影响。 The change should only be to make www.123456.com to 789.123.com
更改仅应将www.123456.com更改为789.123.com
I've never done this type of manipulation with MYSQL before, so was hoping for a bit of guidance before I hose my entire database of about 4000 records :) I will be doing this through PHPMYADMIN 我以前从未使用MYSQL进行过这种类型的操作,因此希望在我整理约4000条记录的整个数据库之前需要一些指导:)我将通过PHPMYADMIN进行此操作。
Thanks for any help!! 谢谢你的帮助!!
您要使用REPLACE()字符串函数
UPDATE `table` SET `innerLink` = REPLACE('www.123456.com', '789.123.com');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.