pg連表更新語法如下:
UPDATE 要更新的表
SET 字段1 = cqt.字段1,
字段2 = cqt.字段2,
FROM
數據來源表 cqt
WHERE
要更新的表.bsm = cqt.bsm
實例:
update table_p as p
set p_name = a.name,p_user = a.user_id,p_type = 'P02'
from (
select x.user_id,x.name,x.p_id from table_u x
join table_p y on x.p_id = y.p_id
) as a where p.p_id = a.p_id;