iluvperl
Programmer
- Jan 22, 2006
- 107
I have a question about sorting a Mysql query twice.
I need to first sort the columns by ID so that only the newest IDs are brought back. Since it's an autoincrement, the largest 10 of the IDs are the newest.
Then I need to sort this by the column Total (highest number first).
I tried the below line but it doesn't work. It's not erroring out but it's not sorting properly. I am new to MySQL.
Can anyone help?
I need to first sort the columns by ID so that only the newest IDs are brought back. Since it's an autoincrement, the largest 10 of the IDs are the newest.
Then I need to sort this by the column Total (highest number first).
I tried the below line but it doesn't work. It's not erroring out but it's not sorting properly. I am new to MySQL.
Can anyone help?
Code:
my $data = qq(SELECT id, url, altavista, yahoo, msn, teoma, google, alltheweb, Total FROM ( SELECT id, url, altavista, yahoo, msn, teoma, google, alltheweb, Total FROM temp ORDER BY id DESC LIMIT 10 ) baz ORDER BY Total desc);