软件教程

替换DISTINCT的方法查找重复记录

来源: 本站    类别: 软件教程    日期: 2012/12/6

 

  通常选择重复记录,都需要用到DISTINCT,但有个不好的地方,就是不能选择多个字段,上网找了良久,在动网发现一个贴解决这个问题,利用的下面的语句:

sql="select a,b from tab where id in (select min(id) from tab group by a)"

  关于Sql的Distinct防止记录重复语句的疑惑

  以前很少用,但现在有个项目要求取出的记录没有重复的

rs.open "select Distinct 会员 from 表1 where 主题=false and 经验>200 order by 会员 desc",link1,1,1

  以上SQL语句可以取出数据库中符合条件的会员(而且可以实现没有反回重复记录),但如果改成以下三种情况,就会出现调不出记录或调出的记录有重复或者调出的记录异常,请问这是为什么?难道Distinct一次指定筛选一个字段?

rs.open "select Distinct * from 表1 where 主题=false and 经验>200 order by 会员 desc",link1,1,1
rs.open "select Distinct 会员,注册日期 from 表1 where 主题=false and 经验>200 order by 会员,注册日期 desc",link1,1,1
rs.open "select Distinct 会员,注册日期 from 表1 where 主题=false and 经验>200 order by 会员 desc",link1,1,1


相关文章


Copyright © 2004 - 2024 CNHWW Inc. All Rights Reserved
石家庄市征红网络科技有限公司版权所有 邮政编码:050051
服务电话:0311-85315152 13931185013 在线客服QQ:81447932 / 81447933 邮箱: cnhww@163.com