Quantcast
Channel: MySQL Forums - Install & Repo
Viewing all articles
Browse latest Browse all 7244

Fetching latest download (1 reply)

$
0
0
Hello, I'm trying to get the latest version for a user and project from the database.The structure of the database is like this:
id pid userid version
1 1 2 0.0.9
2 2 2 0.0.4
3 3 2 0.0.2
4 4 2 0.0.1
5 5 2 0.0.3
6 6 2 0.0.5
7 7 2 0.1.0
9 1 3 0.0.9
10 6 3 0.0.5
12 6 3 0.0.6

So for userid 3 I would get the following 2 rows:
9 1 3 0.0.9
12 6 3 0.0.6

I experimented using MAX(), but it still returned 0.0.5 to be the latest version, however the id was correct..something like:
SELECT id as latest,pid,userid,version FROM thc_dl WHERE userid='3' GROUP BY pid ORDER BY id DESC
And lots of variants, but none seemed to return the results that I wanted, what am i doing wrong?

Thanks in advance.

Viewing all articles
Browse latest Browse all 7244

Trending Articles