现在的位置: 我的问答 >mysql子查询时group by不是取的第一条数据

mysql子查询时group by不是取的第一条数据

2020-04-28 00:38 ⁄ 被浏览 664

子查询时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;

结果:

image.png


改为(需要加入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;

结果:

image.png