回 帖 发 新 帖 刷新版面

主题:求救 怎么样得到一个表里重复字段只显第一条记录 同时得到该记录的其他字段值

求救 怎么样得到一个表里重复字段只显第一条记录 同时得到该记录的其他字段值

回复列表 (共3个回复)

沙发

用distinct

rs.Open "select distinct "重复字段" *  from [table] order by id asc",conn,1,1

板凳

--假设取重复name中id最小的记录
select * from tb a
where not exists(select 1 from tb where name=a.name and id<a.id)

3 楼

--或者:
select * from tb
where id in (select min(id) from tb group by name)

--或者:
select * from tb a
where id=(select min(id) from tb where name=a.name)

我来回复

您尚未登录,请登录后再回复。点此登录或注册