I have the following query that does what I want, but I suspect that this can be done without a subquery:
SELECT *
FROM (SELECT *
FROM 'versions'
ORDER BY 'ID' DESC) AS X
GROUP BY 'program'
I need a program group, but returning results for objects in versions with the highest "ID" value.
In my past experience, such a query should work in MySQL, but for some reason this is not the case:
SELECT *
FROM 'versions'
GROUP BY 'program'
ORDER BY MAX('ID') DESC
What I want to want is to do MySQL first ORDER BY and then GROUP BY, but he insists on doing GROUP BY first and then ORDER BY first. those. it sorts the grouping results instead of grouping the ordering results.
Of course write
impossibleSELECT * FROM 'versions' ORDER BY 'ID' DESC GROUP BY 'program'
Thank.