Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将行复制到选择column1 value = 55的同一张表和column 1 value = 56的新行,如果我们第二次运行查询,它不应该再次复制旧行
您可以使用以下命令添加一个where子句以防止重复插入not exists:
where
not exists
insert YourTable (col1, col2, col3, ...) select 56 -- New value , col2 , col3 , ... from YourTable where col1 = 55 -- Old value and not exists ( select * from YourTable where col1 = 56 -- New value )