It was very difficult to find the words for the title, but hopefully the problem is easily described. I have a table:
+------------+----------------+---------------------+
| identifier | version_number | name |
+------------+----------------+---------------------+
| 1 | 1 | propositional-logic |
| 2 | 2 | propositional-logic |
| 3 | 3 | propositional-logic |
| 4 | 1 | natural-numbers |
| 5 | 4 | propositional-logic |
| 6 | 2 | natural-numbers |
| 7 | 3 | natural-numbers |
| 8 | 4 | natural-numbers |
| 9 | 5 | propositional-logic |
+------------+----------------+---------------------+
I want to get the 'latest version' for each name, returning the name and the identifier. I have gotten this far with a query:
select max(version_number),name from `release` group by name;
This comes close, returning the right version numbers and names...
+---------------------+---------------------+
| max(version_number) | name |
+---------------------+---------------------+
| 4 | natural-numbers |
| 5 | propositional-logic |
+---------------------+---------------------+
...but I need the identifiers, too. If I try the query...
select max(version_number),name,identifier from `release` group by name;
...I get an error. I think I understand where I am going wrong, but cannot find away around it.
Any help would be greatly appreciated. Also, if anyone more experienced than me can think of a more descriptive title, please go right ahead and change it!