View Single Post
Old 10-24-2007, 11:55 AM   #3 (permalink)
bluesaga
Super Moderator
Advanced Programmer 
 
bluesaga's Avatar
 
Join Date: Sep 2007
Posts: 165
Thanks: 0
bluesaga is on a distinguished road
Default

Gurnk, i don't think you understand him.

On such a small dataset it wouldn't be very good to use mysql the way i propose and use PHP instead, however with a larger dataset i see why you would be concerned.

The method i recommend to fix this would be to use a sub-query to fetch the ID's to rank for like so:

PHP Code:
SELECT
    t
.*
FROM
    
(SELECT FROM table ORDER BY lastname ASC LIMIT 0,5t
ORDER BY
    t
.lastname DESC 
Note: This is not tested and may not work, but it should do :)

What this does, is create a result set to work with first (temporary table) and then do the ordering after.

Last edited by bluesaga : 10-24-2007 at 11:57 AM. Reason: [code] looks horrible, [php] is much nicer
bluesaga is offline  
Reply With Quote