SQL, problem with OrderBy / GroupBy
Posted
by
Tristan
on Stack Overflow
See other posts from Stack Overflow
or by Tristan
Published on 2011-02-10T15:09:14Z
Indexed on
2011/02/10
15:25 UTC
Read the original article
Hit count: 227
Hi,
In my table I have two fields among others : article_id and *version*
*example:
article_id : 5 // version 1
aricle_id: 5 // version 2
article_id: 6 // version 1*
What i want to do is to retrieve the latest version for each article id (in my example i want to retrieve the article 5 version 2 object and article 6 and version 1 object).
The problem is that mysql is doing the groupBy instead of the OrderBy so it returns to me the FIRST version of each article, but i want the opposit.
Do you have an idea please ?
© Stack Overflow or respective owner