In my particular database table, I have many rows which its common element is the `username`, now the most unique and method I wish to order on, is `time` (timestamp). In my code my base query currently is:
SELECT `username` FROM `download_counter` GROUP BY `username` ASC
Which then as expected, on page rows are ordered by username in alphabetical order. What I wish to do is, on page view, rows are ordered by the `time` value. However heres my two problems:
For starters it probably comes to no surprize that when using GROUP BY, the query remembers the first row it comes across and ignores the laters, so if there are three rows, oviously the first one it finds is the earliest of times, which is exact opposite of what I want. My other problem involves my attempt at a query:
SELECT `username` FROM `download_counter` ORDER BY `time` DESC GROUP BY `username`
this brings back:
#1064 - You have an error in your SQL syntax ... near 'GROUP BY `username`
I guess a ORDER cannot be before a GROUP.
But then what do I do? Is there a way maybe to query all results, then after that preform a GROUP?