update vehicles_vehicle v join shipments_shipment s on v.shipment_ID=s.ID set v.price=s.price_per_vehicle;
我相信这将工作在MysqL(我的背景),但它似乎不工作在postgres。我得到的错误是:
ERROR: Syntax error at or near "join"liNE 1: update vehicles_vehicle v join shipments_shipment s on v.shi... ^
当然有一个简单的方法来做到这一点,但我找不到正确的语法。那么,我该如何在Postgresql中写这个?
UPDATE syntax是:[ 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 vehicles_vehicle AS v SET price = s.price_per_vehicleFROM shipments_shipment AS sWHERE v.shipment_ID = s.ID总结
以上是内存溢出为你收集整理的如何做一个更新加入PostgreSQL?全部内容,希望文章能够帮你解决如何做一个更新加入PostgreSQL?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)