我有一个sql语句,如下所示:
select c.*
from manga_chapter c join
(select manga_source_id, max(manga_episode_number) as maxmen
from manga_chapter
group by manga_source_id
) cc
on c.manga_source_id = cc.manga_source_id and
c.manga_episode_number = cc.maxmen;
我想添加另一个
表select manga_picture, manga_description from manga;
连接
a是manga_source表,b是漫画表
where a.source_id = b.source_id
如何在上面的顶级sql语句中一起绘制manga_picture,manga_description。
我试过
select c.*
from manga_chapter c join
(select manga_source_id, max(manga_episode_number) as maxmen
from manga_chapter
group by manga_source_id
) cc join
(select manga_name,manga_picture
from manga) ccc
on c.manga_source_id = cc.manga_source_id and
c.manga_episode_number = cc.maxmen and
ccc.manga_id = c.manga_id;
我得到的错误是
Unknown column 'ccc.manga_id' in 'on clause'