【PostgreSQL】多表关联数据怎么update

更新移动库存表(warehouse_inventoryrecords)的code_

移动库存表关联出库明细表(warehouse_outbounditems

code_ 来自出库表(warehouse_outbounds





update warehouse_inventoryrecords  as wi

set code_ = a.code_
 from (select woi.id_, wo.code_ from  warehouse_outbounditems as woi 
inner join  warehouse_outbounds as wo on woi.outboundid_ = wo.id_) as a
where wi.type_ = 'OUT' and wi.inandoutanddeliveryid_ = a.id_ 

你可能感兴趣的:(Database)