不灭的焱

加密类型:SHA/AES/RSA下载Go
复合类型:切片(slice)、映射(map)、指针(pointer)、函数(function)、通道(channel)、接口(interface)、数组(array)、结构体(struct) Go类型+零值nil
引用类型:切片(slice)、映射(map)、指针(pointer)、函数(function)、通道(channel) Go引用

作者:AlbertWen  添加时间:2023-04-02 18:21:35  修改时间:2025-12-04 18:29:17  分类:03.MySQL/PgSQL/Redis  编辑

SQL 查询出 重复的数据:保留 id 最大值的记录

本地测试 案例

(1)查询 重复数据:

select a.* from "albert_test_a" a where exists (select b.* from "albert_test_a" b where b."email" = a."email" and b.id> a.id)

(2)删除 重复数据:

delete from "albert_test_a" a where exists (select b.* from "albert_test_a" b where b."email" = a."email" and b.id> a.id)

 


 

织信低代码系统  案例

(1)查询 重复数据:

select a.* from "z_0Z6t6t3lczX7fhcH" a where exists (select b.* from "z_0Z6t6t3lczX7fhcH" b where b."0Z6t6t3eN2K8U1Yj" = a."0Z6t6t3eN2K8U1Yj" and b.row_number > a.row_number)

(2)删除 重复数据:

delete from "z_0Z6t6t3lczX7fhcH" a where exists (select b.* from "z_0Z6t6t3lczX7fhcH" b where b."0Z6t6t3eN2K8U1Yj" = a."0Z6t6t3eN2K8U1Yj" and b.row_number > a.row_number)