假设我有两个表(省略了非必要行):
Table `pages`
page_id | page_key
1 | home
2 | about
和
Table `page_versions`
page_id | page_version | page_title | page_content
1 | 2 | Home | Lorem Ipsum...
1 | 4 | Home | Dolor Sit...
2 | 3 | About | Nunc Nisl...
2 | 5 | About | Proin Alt...
如果每个page
都有多个page_version
s,我如何查询数据库以使所有page
s 与它们的最新相关联page_version
?
本质上:
page_id | page_key | page_version | page_title | page_content
1 | home | 4 | Home | Dolor Sit...
2 | about | 5 | About | Proin Alt...