带有连接的 Postgresql 更新 [英] Postgresql Update with join
本文介绍了带有连接的 Postgresql 更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想加入 2 个表并更新第 2 个表的指定值上的第一个表的值.我使用其他解决方案失败.
I want to join 2 tables and update value of firts table on specified value of 2nd table. I failed using others solutions.
UPDATE customers
SET cutoffstop = cutoffstop + '432000'
FROM customers as c
JOIN bluemedia as b ON c.id = b.customerid
WHERE b.orderid = '217201807'
推荐答案
一般更新语法:
[ WITH [ RECURSIVE ] with_query [, ...] ]
UPDATE [ ONLY ] table [ [ AS ] alias ]
SET { column = { expression | DEFAULT } |
( column [, ...] ) = ( { expression | DEFAULT } [, ...] ) } [, ...]
[ FROM from_list ]
[ WHERE condition | WHERE CURRENT OF cursor_name ]
[ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]
解决您的问题:
UPDATE customers AS c
SET cutoffstop = cutoffstop + 432000
FROM bluemedia as b
WHERE c.id = b.customerid
AND b.orderid = '217201807'
有关 UPDATE
语法的更多信息,请访问以下链接:
For more information on UPDATE
syntax follow the below link:
https://www.postgresql.org/docs/current/静态/sql-update.html
这篇关于带有连接的 Postgresql 更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文