如何从另一个表中将数据插入表中而不重复。 [英] How to insert data into table from another table without duplicates.
本文介绍了如何从另一个表中将数据插入表中而不重复。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从另一个表中将数据插入到表中,但我得到重复。
任何正文都会给我我需要添加删除查询的位置。
I am inserting data into table from another table, But I am getting duplicates.
Any body give me where I need to add delete query.
Insert into tb2(fields)
select * from tb1;
以上查询我需要添加删除查询以删除重复记录。
sol:
So above query where I need to add delete query for deleting duplicate records.
sol:
推荐答案
您需要使用本文所述的子查询: Oracle SQL子查询类型,而不是in,存在 [ ^ ]。
示例:
You need to use subquery as is described in this article: Oracle SQL subquery types in, not in, exists[^].
Example:
Insert into tb2(Field1, Field2)
SELECT Field1, Field2
FROM tb1
WHERE NOT EXISTS (SELECT Field1 FROM tb1) ;
这篇关于如何从另一个表中将数据插入表中而不重复。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文