MySQL Forums
Forum List  »  General

Re: Record Position in Ordered Selection
Posted by: Rick James
Date: June 06, 2009 05:43PM

It could be done:
CREATE TEMPORARY TABLE Tmp (
   rank INT UNSIGNED AUTO_INCREMENT NOT NULL,
   listing_id ...
)
   SELECT NULL, listing_id
     FROM Rankings
     ORDER BY ranking
     LIMIT 1000;
SELECT rank FROM Tmp 
   WHERE listing_id = ...;
It won't be fast -- it needs to go through all(?) of Rankings, then all of Tmp.
But doing it in PHP (or whatever) won't be fast either.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.