首页 > 解决方案 > 如何在 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;

标签: postgresql

解决方案


请尝试以下 SQL:

with t as (
update  weighttracker
set wet_currentweight = 112
where wet_cid = 88
)
update  client  
set c_weight = 112  
where c_id = 88;

推荐阅读