Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有可能在mysql中修改相同的内容?_Mysql - Fatal编程技术网

有没有可能在mysql中修改相同的内容?

有没有可能在mysql中修改相同的内容?,mysql,Mysql,我在一列中为每条记录提供了以下值: http://192.168.106.82/bookclub/uploads/booktype/01_type_education.png http://192.168.106.82/bookclub/uploads/booktype/02_type_religion.png http://192.168.106.82/bookclub/uploads/booktype/03_type_technology.png http://192.168.106.82/

我在一列中为每条记录提供了以下值:

http://192.168.106.82/bookclub/uploads/booktype/01_type_education.png
http://192.168.106.82/bookclub/uploads/booktype/02_type_religion.png
http://192.168.106.82/bookclub/uploads/booktype/03_type_technology.png
http://192.168.106.82/bookclub/uploads/booktype/04_type_business.png
http://192.168.106.82/bookclub/uploads/booktype/05_type_healthy.png
http://192.168.106.82/bookclub/uploads/booktype/06_type_magazine.png
http://192.168.106.82/bookclub/uploads/booktype/07_type_literature.png
然后我想将IP地址192.168.106.82修改为其他地址,如192.168.1.39
我可以一次修改所有这些吗?

您可以在UPDATEs的SET子句中使用函数,如下所示:

UPDATE table 
SET field = REPLACE(field, 'old value', 'new value')
WHERE condition

要更新整个表,您可以完全关闭WHERE子句,或者设置一个不能为false的条件(某些服务器配置阻止WHERLES更新)。

您可以使用update

UPDATE your_table
SET your_field = REPLACE(your_field, '192.168.106.82', ' 192.168.1.39')
WHERE your_field LIKE '%192.168.106.82%'

如果
您的_字段
已被索引,则使用
LIKE可能会更好http://192.168.106.82%“
@uuerdo。。可能是。。但问题在本质上是一样的。。还有别的办法。。与…无关。。。是否可以使用子字符串。。或者其他方式。。我的建议很清楚,可以立即使用是的,不是批评或其他什么,只是想把它作为旁注。@uuerdo。。是的,你的建议是合理的。。我同意。我尝试了以下语句:UPDATE books SET imageurl=REPLACE(imageurl,'192.168.106.82','192.168.1.39'),其中imageurl类似于'%192.168.106.82%',但我发现了一些错误,找到了一条新语句,但在它和上一条语句之间没有分隔符。(靠近替换)