我有两个表,用户和帖子。我正在尝试编写一个查询来查找用户的最新帖子,但我遇到了麻烦。这是我到目前为止所拥有的。
select a.username, b.last_post from logins as a join (select login_id, entry as last_post from posts) as b where a.id = b.login_id
+-----------+---------------------+
| username | last_post |
+-----------+---------------------+
| something | 2013-10-08 22:12:00 |
| other | 2013-10-08 22:13:00 |
| test | 2013-10-08 22:13:03 |
| test | 2013-10-08 22:14:20 |
| hello | 2013-10-08 22:12:53 |
| hello | 2013-10-08 22:12:56 |
+-----------+----------+----------+
所以现在last_post
只是它正在拉的帖子的时间戳。如何获得仅显示这些用户的最后一篇文章的表格?