如何在两个表之间查找重复数据并在一个表上删除 [英] How to find duplicate data between two tables and delete on one
本文介绍了如何在两个表之间查找重复数据并在一个表上删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两张桌子:
表 1
表 2
如您所见,两个表上的确认编号 (121449) 相同,并且具有相同的 3/4 日期.
As you can see, the confirmation number (121449) is the same on both tables and have the same 3/4 dates too.
我想删除表 1 的 3 行,因为它们在表 2 上.
I would like to delete that 3 rows of table 1 because they are on table 2.
推荐答案
为此使用 join.
DELETE T1 -- Make sure only include T1 here.
FROM tb_allinc_sin_trace T1
INNER JOIN tb_outdoors T2 ON T1.confirmation_number = T2. confirmacion_nro
WHERE T1.dates = T2.servicio_fecha;
要验证哪些记录将被删除,您可以使用 select 语句.
To verify which records will be deleted, you can use select statement.
SELECT *
FROM tb_allinc_sin_trace T1
INNER JOIN tb_outdoors T2 ON T1.confirmation_number = T2. confirmacion_nro
WHERE T1.dates = T2.servicio_fecha;
参考:
这篇关于如何在两个表之间查找重复数据并在一个表上删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文