我想将tableA中记录的所有记录与value3 = True一起插入tableB。然后我想在tableA中删除这些记录。我想在一个语句中执行此操作并尝试运行以下SQL语句
DELETE FROM
TableA
WHERE
rowID IN (INSERT INTO TableB (Value1, Value2)
SELECT Value1, Value2 FROM TableA WHERE Value3=TRUE RETURNING rowID)
但它不起作用。如何修复此SQL以使其按计划运行?
答案 0 :(得分:1)
为什么不分成两个命令?
insert into TableB
select * from TableA where value3 = True
delete from TableA
where rowID in (select * from TableA where value3 = True)