[英]Select Find and replace query Mysql
How to figure out this query: 如何找出这个查询:
I want to find in column details where matches image.GIF with this query: 我想在列详细信息中找到与此查询匹配的image.GIF:
SELECT * FROM `news` WHERE details LIKE '%image.GIF%'
Then I have other column 'title' I want to rename these entries on 'title column' where related to above query. 然后我有另一个列“标题”,我想重命名“标题列”中与上述查询相关的这些条目。
UPDATE `news`
SET `details` = replace(details, 'image.GIF', 'new_image.GI')
I hope It's understandable. 我希望这是可以理解的。
Column details - in this column to find all rows with text image.gif; 列详细信息-在此列中查找包含image.gif文本的所有行;
Column title - to rename all things inside to new_image.gif where belonging to details column; 列标题-将内部所有内容重命名为new_image.gif并属于详细信息列;
Include the condition into a WHERE
clause like 将条件包含在
WHERE
子句中,例如
UPDATE `news`
SET `title` = replace(title, 'image.GIF', 'new_image.GI')
WHERE details LIKE '%image.GIF%';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.