Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.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数据库中添加url?_Mysql - Fatal编程技术网

如何在字段中查找字符串并在mysql数据库中添加url?

如何在字段中查找字符串并在mysql数据库中添加url?,mysql,Mysql,我想知道如何在表字段中查找字符串的所有可能实例,例如 uploads/ http://example.com/ 并在所有字符串之前添加另一个字符串,例如 uploads/ http://example.com/ 我的想法是更新数据库中旧链接不起作用的所有记录,因此对于Instance,我有类似于perex的字段 Check this car <img src="/uploads/audi.jpg">. It is fantastic! 检查这辆车。太棒了! 看起来像: C

我想知道如何在表字段中查找字符串的所有可能实例,例如

uploads/
http://example.com/
并在所有字符串之前添加另一个字符串,例如

uploads/
http://example.com/
我的想法是更新数据库中旧链接不起作用的所有记录,因此对于Instance,我有类似于perex的字段

Check this car <img src="/uploads/audi.jpg">. It is fantastic!
检查这辆车。太棒了!
看起来像:

Check this car <img src="http://example.com/uploads/audi.jpg">. It is fantastic!
检查这辆车。太棒了!
我的数据库中有数百种这种情况

更新查询会是什么样子?假设我们在一个名为cars的表中有它,字段名为perex。我们需要找到所有/uploads的实例,并在斜杠前添加http://example.com/

提前谢谢你的回答

UPDATE cars
SET perex = REPLACE(perex, '/uploads/', 'http://example.com/uploads/')
WHERE INSTR(perex, '/uploads/');
见:

试试这个

Update table
set Perex = Replace (Perex, 'Check this car <img src="', 'Check this car <img src="http://example.com')
Where Perex like '%uploads/%'
更新表
设置Perex=更换(Perex,'检查这辆车