答案 0 :(得分:1)
尝试
select
a.*
from
article as a
WHERE
a.id IN (SELECT MAX(id) FROM article GROUP BY author_id);
如果您想要作者详细信息,请尝试
select
a.*,au.name,au.image
from
article as a,
autor as au
WHERE
a.id IN (SELECT MAX(id) FROM article GROUP BY author_id)
AND
a.author_id = au.id;
演示
答案 1 :(得分:1)
对此的正确查询如下。
select * from article a
where a.date >= all (select b.date from article b where a.author_id = b.author_id)
如果这太慢,那么您可以在(author_id, date)
表上尝试article
的索引。请注意,索引中列的顺序很重要。 author_id
必须是第一个。
答案 2 :(得分:0)
SELECT * FROM
(SELECT * FROM author, article WHERE author.id=article.author_id order by date DESC)
tab group by id
这是获取作者最新文章的正确查询。