我有一个查询列出所有帖子:
SELECT *, DATE(FROM_UNIXTIME(`timestamp`)) `date` FROM `posts` ORDER BY `date` DESC
查询列出所有行,我只希望每行显示最后2条帖子date,我该怎么做?
date
这可能有用,尽管我不能说太多性能。
SELECT DATE(FROM_UNIXTIME(MyTimestamp)) AS ForDate, * FROM MyPostsTable WHERE 2 >= ( SELECT COUNT(*) FROM MyPostsTable AS lookup WHERE DATE(FROM_UNIXTIME(lookup.MyTimestamp)) = DATE(FROM_UNIXTIME(MyPostsTable.MyTimestamp)) AND lookup.MyTimeStamp >= MyPostsTable.MyTimestamp )