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
是的。我试图避免更新,因为几何复杂性 –