热搜词
发表于 2008-4-15 22:27:46 | 显示全部楼层 |阅读模式
//查询单列重复记录
SELECT COLUMN_1,COUNT(*) FROM TABLE_NAME GROUP BY COLUMN_1 HAVING COUNT(*)>1

//查找两列重复记录
SELECT COLUMN_1,COLUMN_2,COUNT(*) FROM TABLE_NAME GROUP BY COLUMN_1,COLUMN_2 HAVING COUNT(*)>1

//查找重复记录的详细信息
SELECT * FROM TABLE_NAME
WHERE COLUMN_1 IN (SELECT CITY_ID
    FROM EQUIP_F_ELECT_RATIO
    GROUP BY COLUMN_1
    HAVING COUNT(*)>1)

//删除数据库中重复记录
select corpname,count(*) from tbcorp group by corpname having count(*) > 1
delete from tbcorp a where a.rowid!=(select min(b.rowid) from tbcorp b where a.corpname = b.corpname)

//删除数据库中重复记录2
delete from where id not in(select min(id) from 表 group by 字段1,字段2,字段3)

[ 本帖最后由 灰儿 于 2008-4-15 22:55 编辑 ]
全部评论0
回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|管理员之家 ( 苏ICP备2023053177号-2 )

GMT+8, 2024-12-23 04:28 , Processed in 0.208106 second(s), 33 queries .

Powered by Discuz! X3.5

Cpoyright © 2001-2024 Discuz! Team