亲测有效。代码如下:
select a.id from app a left join (select uid,id,name from weixin group by uid) b on a.id=b.uid
如上代码段所示,依据uid判断重复的记录,group by ,只显示一条记录。
若是group by查询较慢,也可这样写,在group by之前增加一个where条件,速度马上就上来。
select a.id from app a left join (select uid,id,name from weixin where 索引条件 group by uid) b on a.id=b.uid