I have a small problem. I’m populating a select tag with results from a SQL database. What I would like to have is the last one added as the top entry and the rest sorted alphabetically.
So it would return:
*----------*-------------* developerID|developerName *----------*-------------* | 40 | ZZZ Dev | | 39 | A Dev | | 38 | Be New Dev | *----------*-------------*
Currently it just selects all the entries in descending order:
'SELECT developerName, developerID FROM developer ORDER BY developerID DESC'
Which is fine, but not as usable as I would like.
Is what I want possible using pure MySQL?
Assuming the column defining when the developer was added is developerAdded (a timestamp of some sort):
If there’s some other magic way to determine the most recently added developer (e.g. maximum developerID), adjust the sub-queries accordingly.
Note that this query works OK even if several developers satisfy the ‘most recently added’ criterion; they appear in alphabetic order before the developers who’ve been around longer.
Since the most recently added developer has the maximum developerID, the revised query should be: