Page 1 of 1

php + mysql.... ORDER twice?

Posted: Mon Aug 07, 2006 6:03 pm
by Citizen
Basically I have a query that finds the top 10 results ordered by the number of votes.

Once I have these 10 results, I want to order them by date, not by results.

Can I do this within the mysql query or would it be better to use php?

Posted: Mon Aug 07, 2006 6:07 pm
by hawleyjr
Like this?

Code: Select all

ORDER BY NO_VOTES DESC, DATE_FIELD DESC LIMIT 0,1
Edit: added limit 0,1

Posted: Mon Aug 07, 2006 6:36 pm
by Citizen
Thanks... what does the limite 0,1 do?

Posted: Mon Aug 07, 2006 6:39 pm
by hawleyjr
Citizen wrote:Thanks... what does the limite 0,1 do?
It was supose to be limit 0,10

This way only the first 10 results are returned ;)

Posted: Mon Aug 07, 2006 6:40 pm
by Citizen
Thanks again.

I've used LIMIT before but I'm unsure why there's a 0 in the 0,10

Wouldnt that return 0 results?

Posted: Mon Aug 07, 2006 6:42 pm
by hawleyjr
no it says start at the first record.

See what happens when you change zero to another number say 5

LIMIT 5,10

Posted: Mon Aug 07, 2006 6:43 pm
by Citizen
Thanks!