PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Citizen
Forum Contributor
Posts: 300 Joined: Wed Jul 20, 2005 10:23 am
Post
by Citizen » Mon Aug 07, 2006 6:03 pm
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?
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Mon Aug 07, 2006 6:07 pm
Like this?
Code: Select all
ORDER BY NO_VOTES DESC, DATE_FIELD DESC LIMIT 0,1
Edit: added limit 0,1
Citizen
Forum Contributor
Posts: 300 Joined: Wed Jul 20, 2005 10:23 am
Post
by Citizen » Mon Aug 07, 2006 6:36 pm
Thanks... what does the limite 0,1 do?
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Mon Aug 07, 2006 6:39 pm
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
Citizen
Forum Contributor
Posts: 300 Joined: Wed Jul 20, 2005 10:23 am
Post
by Citizen » Mon Aug 07, 2006 6:40 pm
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?
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Mon Aug 07, 2006 6:42 pm
no it says start at the first record.
See what happens when you change zero to another number say 5
LIMIT 5,10
Citizen
Forum Contributor
Posts: 300 Joined: Wed Jul 20, 2005 10:23 am
Post
by Citizen » Mon Aug 07, 2006 6:43 pm
Thanks!