浏览 1881 次
锁定老帖子 主题:删除完全相同的记录
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-05-20
如果没有递增字段可以采用临时表技术 SELECT DISTINCT * INTO #tempTable FROM sourceTable DELETE FROM sourceTable INSERT INTO sourceTable SELECT * FROM #tempTable DROP TABLE #tempTable 如果删除的表中存在自动增长列 如: pid pname 2,"b" 6,"c" 14,"d" 15,"h" 16,"k" 17,"e" 18,"a" 19,"c" 20,"k" 21,"b" 可以采用如下SQL语句 DELETE FROM PInfo WHERE (pid NOT IN (SELECT MAX(pid) FROM pinfo GROUP BY pname)) 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |