如何在其他表中查找重复的行

时间:2019-08-31 17:03:59

标签: mysql

我的问题:我有两个MySQL表。一个表称为 txns ,另一表称为 archived_txns 。两个表都有相同的列。我使用 archived_txns 使用PHP脚本从 txns 中移动数据。

我想知道如何查找和删除这两个表中的重复行我正在添加表结构以供更好地参考。

  

这是 archived_txns

tutorial

  

这是 txns

enter image description here

如本例所述,我想从 txns 表中查找并删除具有 ID 3 的行。

1 个答案:

答案 0 :(得分:1)

您可以使用JOIN

删除它
DELETE t 
FROM txns t
JOIN archived_txns a ON t.id = a.id