子查询时group by不是取的第一条数据,mysql版本为5.7,在5.5中没问题。
查询语句如下:
SELECT * FROM (SELECT id,uid FROM photo WHERE uid IN (4655,6282) AND ispass=1 ORDER BY id DESC) AS tt GROUP BY uid;
结果:
改为(需要加入limit限制):
SELECT * FROM (SELECT id,uid FROM photo WHERE uid IN (4655,6282) AND ispass=1 ORDER BY id DESC LIMIT 100000) AS tt GROUP BY uid;
结果: