MySQL Forums
Forum List  »  General

Re: Row Number Variable?
Posted by: ajay sharma
Date: November 25, 2008 05:50AM

Sean Daniels Wrote:
-------------------------------------------------------
> Is there a built in function in MySQL for
> returning the current row number in a result set?
>
> i.e.: select id, func() as myrow from table
>
> id myrow
> ---- ----------
> 10 1
> 11 2
> 12 3



Hi,

try this
SELECT @rownum:=@rownum+1 rownum, mytable.*
FROM (SELECT @rownum:=0) r, mytable;

Options: ReplyQuote


Subject
Written By
Posted
January 21, 2008 01:45PM
January 21, 2008 02:40PM
September 07, 2008 07:28PM
Re: Row Number Variable?
November 25, 2008 05:50AM


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.