MySQL - given multiple associations, how to get latest association for
several records?
Let's say I have two tables (non-essential rows omitted):
Table `pages`
page_id | page_key
1 | home
2 | about
and
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...
If each page has multiple page_versions, how do I query the database such
that I get all pages associated to their latest page_version?
Essentially:
page_id | page_key | page_version | page_title | page_content
1 | home | 4 | Home | Dolor Sit...
2 | about | 5 | About | Proin Alt...
No comments:
Post a Comment