View Single Post
Old 02-18-2011, 09:49 PM  
Jakez
Confirmed User
 
Jakez's Avatar
 
Industry Role:
Join Date: Jan 2004
Location: oddfuturewolfgangkillthemall!!!!!!!
Posts: 5,656
Quote:
Originally Posted by sarettah View Post
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
I tried a sub select earlier, it gave me this error earlier and gives me the same error trying this one.

#1248 - Every derived table must have its own alias


I think sub select is meant to be used with multiple tables? Idk I've never used em..

Edit: oh I needed to place it into an alias like

select * from (select * from tablename order by id desc limit X,14) as aliasname order by views desc

Does the trick thanks dude!
__________________
[email protected] - jakezdumb - 573689400

Killuminati

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