您可以将子查询移到该
having子句。正如戈登回答的那样,您将
having第二个子句用作第二个子句
where,只有MySQL支持。最好在
wherewith中添加第二个条件
and:
SELECt e.idFROM events eWHERe author_id = 32 AND e.id >= (SELECt MIN(u.id) id FROM (SELECt MIN(id) id FROM events WHERe author_id = 32 GROUP BY type, post_id, table_pre, comment_id, context ORDER BY MIN(id) desc LIMIT 15) as u ) ORDER BY id DESC
根据您的评论,这会更简单一些。它选择事件ID最高的15个帖子:
SELECt idFROM eventsWHERe author_id = 32 AND post_id IN ( SELECt DISTINCT post_id FROM events ORDER BY id DESC LIMIT 15 )



