I have a table called documents
that has the fields id, title, version and content.
Now I want to get all ids (or rows) for every title with the highest version.
Suppose I have the following data:
+----+-------+---------+---------+
| id | title | version | content |
+----+-------+---------+---------+
| 2 | foo | 1 | abc1 |
| 3 | foo | 2 | abc2 |
| 4 | foo | 3 | abc3 |
| 5 | bar | 1 | abcd1 |
| 6 | bar | 2 | abcd2 |
| 7 | baz | 1 | abcde1 |
+----+-------+---------+---------+
I want to receive either the ids 4,6,7 or the whole rows for these entries.
Performance is not an issue as there will be only a few hundred entries.