View Single Post
Old 02-18-2011, 09:44 PM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,066
Quote:
Originally Posted by Jakez View Post
Nah sorting by ID (which pretty much goes in order just like the dates) because I need exactly 14 posts on each page regardless of how many were posted that day.

I've got it working how I want now, I just queried the latest 14 posts, stuck them in a multidimensional array and sorted that by views. Next page will grab the next 14 and sort them by views, etc..

Still don't understand why using 2 ORDER's in a query isn't working..
You can do it in a sub select but you can't do it the way you are trying to do it.

The order by clause on your query is saying to sort the entire table by the order by clause and then give you the 14 you want. You dont want the entire table sorted by views, you just want the 14 that will be on your current page sorted by views.

To do it in one query (which is actually 2) and get the results you want would be:

select * from (select * from tablename order by id desc limit X,14) order by views desc
__________________
All cookies cleared!

Last edited by sarettah; 02-18-2011 at 09:46 PM..
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote