绝世剑神林辰几个女主:关于连接查询和过滤重复记录的sql语法

来源:百度文库 编辑:神马品牌网 时间:2024/05/12 20:19:11
asp中有这样一句
sql="select b.pid,a.id,b.title,b.titlecolor,b.hits,b.re,b.username,b.lastreplyuser,b.lastreplytime,b.setlock,b.setbest,b.settop,b.itime from infoindex a left join infos b on a.id=b.id where b.settop=2 or a.pid in ("&neighborgroups&")"

选出来后,有很多重复记录
我想选择id唯一的记录,但sql="select b.pid,distinct(a.id),b.title,b.titlecolor,b.hits,b.re,b.username,b.lastreplyuser,b.lastreplytime,b.setlock,b.setbest,b.settop,b.itime from infoindex a left join infos b on a.id=b.id where b.settop=2 or a.pid in ("&neighborgroups&")"也出错,
请问怎么办?

可以考虑group by id