mysql select order by question
Posted: Fri Dec 03, 2004 4:21 am
I have a table that contains bandnames, an ID and a URL.
It is perfect possible that a bandname appears twice or more.
Somewhere on my website I have a drop down list that displays the bandnames, alphabetically, grouped by bandname.
I want the option value to be the latest ID (highest number) that corresponds with the bandname.
I thought this would have been the solution, but it appears not to work:
SELECT ID, bandname, URL from bands GROUP BY bandname ORDER BY bandname ASC, ID DESC
It is perfect possible that a bandname appears twice or more.
Somewhere on my website I have a drop down list that displays the bandnames, alphabetically, grouped by bandname.
I want the option value to be the latest ID (highest number) that corresponds with the bandname.
I thought this would have been the solution, but it appears not to work:
SELECT ID, bandname, URL from bands GROUP BY bandname ORDER BY bandname ASC, ID DESC