我有 2 个表,项目/图像相关:
[project]
project_id (int primary key)
completed (date)
[project_media]
project_media_id (int primary key)
project_id (int foreign key)
image (varchar)
我要选择的是:
从基于已完成的最后5个项目记录中,取最后一个基于project_media_id添加的图像。
换句话说,从最后 5 个项目中插入的最后一个图像。
到目前为止我所拥有的:
select project.completed, project_media.project_id, project_media.image
from project
inner join project_media
on project.project_id = project_media.project_id
order by completed desc limit 5