mysql - 多行更新麻烦mysql
问题描述
我正在尝试替换单个表中的列数据。
有表'catalog_category_product':
'位置','旧位置','category_id','product_id'。
仅当 category_id = 9 继承我的查询时,我才想将 'old_position' 替换为 'position':
UPDATE catalog_category_product
SET catalog_category_product.old_position =
(
select position
FROM (select * from catalog_category_product) AS m2
WHERE category_id = 110
)
WHERE category_id = 9`
解决方案
尝试这个:
Update catalog_category_product as c1, catalog_category_product as c2 set c1.old_position = c2.position where c2.category_id = 110 and c1.category_id = 9
推荐阅读
- java - Spring 从 POST 重定向到 GET 并让后退按钮返回上一页而不是同一页
- python - 按距离和分数过滤点列表
- javascript - Javascript 解析日期 Contract_End_Date
- android - 在 Kotlin Multiplatform 上复制到剪贴板
- google-cloud-platform - 系统尚未使用 systemd 作为 init system (PID 1) 引导。不能操作。无法连接到总线:主机已关闭
- sql - NoSQL 或 SQL 或其他用于缩放 Excel 电子表格的工具
- node.js - Graphql Mysql - 从 JSON 格式的表中获取行
- excel - VBA Excel 中的索引匹配函数的错误处理
- c# - 如何在带有 LINQ 的子查询中使用 GroupBy()?
- javascript - 如何将分页应用于 json-server 中的子对象?