我的数据库中的In this image there are two kavya with differnt id's ... but every field same for that 2 rows... I need to echeck atleast 5 fields and if those five fileds are found to be same means i want to delete one row and keep one存储了重复的记录。除了id之外的每一列对于两行都是相同的...现在,我需要删除两条重复记录中的一条,并确保其中一条记录的安全
发布于 2019-10-12 13:13:09
Delete from table_Name A
Where exists (select 1
From table_Name B
Where A.id = B.id
);
发布于 2019-10-12 13:13:22
在MySQL中,您可以将join
与delete
一起使用
delete t
from t join
(select t.col1, t.col2, . . . ., min(t.id) as min_id
from t
group by t.col1, t.col2, . . .
) tt
using (col1, col2, . . . )
where t.id > tt.min_id;
发布于 2019-10-12 13:14:11
你会想要这样的东西:
DELETE FROM tbl_name WHERE condition LIMIT 1
条件将找到这两行。LIMIT
将只删除其中的一个。
请阅读MySQL的[DELETE][1]
。
https://stackoverflow.com/questions/58354487
复制相似问题