MySQL Forums
Forum List  »  General

Re: Finding a record's position when sorted
Posted by: Peter Brawley
Date: November 14, 2006 09:56PM

SQL Server has a Row_Number() func. MySQL does not. You can create one in a temp table eg

SET @ord=0;
CREATE TABLE temp
SELECT @ord:=@ord+1 AS ord, ...
FROM tbl
ORDER BY ...;

Then join to the temp table in your reproting query.

PB

Options: ReplyQuote


Subject
Written By
Posted
Re: Finding a record's position when sorted
November 14, 2006 09:56PM


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.