Distinct与ID字段的问题,在线等待

zergs 2002-06-22 07:27:18
原表有ID,姓名,性别等字段,但是无意中有些记录重复.我想清除重复记录,但仍要保持ID字段(字段内容可以改变),我按下面方法做,没了ID字段.怎么办?
conn.Execute "select distinct(*) into 临时表 from 原表"
conn.Execute "delete from 原表"
conn.Execute "select * into 原表 from 临时表"
conn.Execute "drop table 临时表"
...全文
289 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zergs 2002-06-23
  • 打赏
  • 举报
回复
我的意思就是将原表中除ID字段外,不重复的数据保留,重复数据清除。(ID字段数值可以改变)。有什么快捷方法?
zergs1 2002-06-23
  • 打赏
  • 举报
回复
还有。。。distinct不能接多个字段???
zergs1 2002-06-23
  • 打赏
  • 举报
回复
自己不能 up3下,只好再注册1个再up。大家help1下嘛。。
请看第3个。。。
zergs 2002-06-22
  • 打赏
  • 举报
回复
up
zergs 2002-06-22
  • 打赏
  • 举报
回复
提前帖子就出错。。只好自己 up1下
zergs 2002-06-22
  • 打赏
  • 举报
回复
非常对不起...题目问错了1些...:-)
1)我用的是adodb
2)
conn.Execute "select distinct 姓名,性别,年龄 into 临时表 from 原表"
conn.Execute "delete from 原表"
conn.Execute "select * into 原表 from 临时表"
conn.Execute "drop table 临时表"
(因为ID不同选distinct也没有用)
duckcn 2002-06-22
  • 打赏
  • 举报
回复

conn.Execute "select distinct(*) into 临时表 from 原表"
conn.Execute "delete from 原表"
conn.Execute "select IDENTITY(int, 1,1) AS ID * into 原表 from 临时表"
conn.Execute "drop table 临时表"

第三句用*不知道可不可以,不行的话,就把表的字段列举出来。

7,789

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧