0
我有兩個表Table_A
和Table_B
。我怎麼能寫一個條件SQL,做以下邏輯有條件刪除並插入postgres
If table A records match table B records on id
then
delete records from table A and Insert records into Table B
我怎樣才能做到這一點與SQL最有可能使用with
delete from Table_A where Exists (select a.id from TABLE_A
join TABLE_B as b on a.id = b.id)
的插入是:Insert into Table_A (id) select id from TABLE_B
是的。我試圖避免更新,因爲幾何複雜性 –