MySQL - Control which row is returned by a group by
问题 I have a database table like this: id version_id field1 field2 1 1 texta text1 1 2 textb text2 2 1 textc text3 2 2 textd text4 2 3 texte text5 If you didn\'t work it out, it contains a number of versions of a row, and then some text data. I want to query it and return the version with the highest number for each id. (so the second and last rows only in the above). I\'ve tried using group by whilst ordering by version_id DESC - but it seems to order after its grouped, so this doesn\'t work.