postgresql - 如何在 posgresql 的一个查询中更新两个表
问题描述
下面是我更新两个表的代码。
update weighttracker , client set weighttracker.wet_currentweight = 112,client.c_weight = 112 where client.c_id = weighttracker.wet_cid and weighttracker.wet_cid = 88;
解决方案
请尝试以下 SQL:
with t as (
update weighttracker
set wet_currentweight = 112
where wet_cid = 88
)
update client
set c_weight = 112
where c_id = 88;
推荐阅读
- flutter - 如何在颤动中打印“用户”实例中的值?
- rx-swift - RxSwift 处理一个订阅调用处理另一个订阅
- azure - Azure Ubuntu VM,即使禁用了 ufw 并为此端口添加了入站规则,也无法访问端口 8080
- python - selenium/python 我无法在下拉列表中选择一个项目
- javascript - 检查jquery中的复选框
- mongodb - 提高性能并了解 IOPS 和 MongoDB 游标的使用
- python - python 一班轮拆分,执行操作,转换为列表
- python - CSV 数据:如何制表和管理
- typescript - 如何使用 Typescript 在 Material-UI 中自定义主题?
- python - 创建了新的 DataFrame 列,无符号最小值小于零