MySQL Forums
Forum List  »  Stored Procedures

circumventing limitations on the "Liimit" clause
Posted by: Dewey Gaedcke
Date: November 13, 2006 05:55PM

Guys,
I'm trying to do paging in a web app. Not being able to specify:
Limit vPageStart vPageEnd
dynamically (using vars) is a hastle. To adjust, I wrote the following SP:

SET @i:=0;
select tbl.RowNum, tbl.part from
(
SELECT @i:= @i+1 as RowNum, substr(ATL_Label,2,6) as part
from Label
Order by part
limit 30
) as tbl
where RowNum between 20 and 25 ;

and it works perfectly because mySQL is setting RowNum (assigning @i) AFTER it performs the "Order by" clause. However, I'm scared to depend upon this behavior because I don't know how or why it knows to delay assignment of RowNum until AFTER the sort. Is this a bug or a feature and can I count on it to keep behaving this way?? Any thoughts or explanations will be very appreciated!!

Options: ReplyQuote


Subject
Views
Written By
Posted
circumventing limitations on the "Liimit" clause
4020
November 13, 2006 05:55PM


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.