postgreSQL实现关联修改

方法一

update test_1 as t1
set name=t2.name
from test_2 as t2
where t1.id = t2.id

方法二

with tem as(
select oet.product,lbnbv.pmd_program_id  
from origin_ems_transactions oet 
join ludp_bq_npi_brs_v lbnbv on upper(lbnbv.pmd_program_name)  = upper(oet .product) 
group by oet.product,lbnbv .pmd_program_id
order by oet.product
)
update origin_ems_transactions
set pmd_program_id = tem.pmd_program_id
from tem 
where origin_ems_transactions.product=tem.product;

你可能感兴趣的:(postgresql)