使用 phpMyAdmin 更新单个列中的所有行
Updating all rows within a single column using phpMyAdmin
有人可以帮我写一个 SQL 语句,我可以用它来更新 MySQL 数据库中的 table 使用 PHPMyAdmin
吗?
背景
我有一个名为 XYZ 的数据库和一个名为 v2rns_content
的 table
table 有很多列,包括一个名为 images
的列
图像列中的每一行都具有相同的内容,除了文件路径不同例如:
{
"image_intro":"images\/news_images\/Logos\/Logo.png",
"float_intro":"",
"image_intro_alt":"",
"image_intro_caption":"",
"image_fulltext":"",
"float_fulltext":"",
"image_fulltext_alt":"",
"image_fulltext_caption":""
}
其中images/news_images/Logos/Logo.png为文件路径。
我想通过添加额外的级别来更新此文件路径,例如
images/news_images/legacy/Logos/Logo.png
问题:
因此是否可以在我的图像列中搜索文本 images/news_images 并将其替换为 images/news_images/legacy此列中的行?
备注:
值得注意的是 v2rns_content table 很难导出(由于大小和特殊字符),否则我只需在 excel 中查找并替换,然后使用 phpMyAdmin 再次导入它。
v2rns_content table 包含超过 20,000 条记录
我不是 SQL 方面的专家,所以如果我能够使用 phpMyAdmin 中的 SQL 函数实现这一点,我将不胜感激(如果可能的话)。
提前感谢您的帮助。非常感谢。
对您的架构没有很好的认识。为了让您使用值更新所有列(相同或不同,取决于您在 PHP 中对其进行的操作)。
这将替换整个值:
UPDATE v2rns_content SET image_intro ='images\/news_images\/legacy'
WHERE image_intro LIKE '%images\/news_images%'
如果您想替换部分目录路径,您可能需要这样做:
UPDATE v2rns_content
SET image_intro = REPLACE(image_intro , 'images\/news_images', 'images\/news_images\/legacy')
这是一个官方参考页面:http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_replace
有人可以帮我写一个 SQL 语句,我可以用它来更新 MySQL 数据库中的 table 使用 PHPMyAdmin
吗?
背景
我有一个名为 XYZ 的数据库和一个名为 v2rns_content
的 tabletable 有很多列,包括一个名为 images
的列图像列中的每一行都具有相同的内容,除了文件路径不同例如:
{
"image_intro":"images\/news_images\/Logos\/Logo.png",
"float_intro":"",
"image_intro_alt":"",
"image_intro_caption":"",
"image_fulltext":"",
"float_fulltext":"",
"image_fulltext_alt":"",
"image_fulltext_caption":""
}
其中images/news_images/Logos/Logo.png为文件路径。
我想通过添加额外的级别来更新此文件路径,例如
images/news_images/legacy/Logos/Logo.png
问题:
因此是否可以在我的图像列中搜索文本 images/news_images 并将其替换为 images/news_images/legacy此列中的行?
备注:
值得注意的是 v2rns_content table 很难导出(由于大小和特殊字符),否则我只需在 excel 中查找并替换,然后使用 phpMyAdmin 再次导入它。
v2rns_content table 包含超过 20,000 条记录
我不是 SQL 方面的专家,所以如果我能够使用 phpMyAdmin 中的 SQL 函数实现这一点,我将不胜感激(如果可能的话)。
提前感谢您的帮助。非常感谢。
对您的架构没有很好的认识。为了让您使用值更新所有列(相同或不同,取决于您在 PHP 中对其进行的操作)。
这将替换整个值:
UPDATE v2rns_content SET image_intro ='images\/news_images\/legacy'
WHERE image_intro LIKE '%images\/news_images%'
如果您想替换部分目录路径,您可能需要这样做:
UPDATE v2rns_content
SET image_intro = REPLACE(image_intro , 'images\/news_images', 'images\/news_images\/legacy')
这是一个官方参考页面:http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_replace