MySQL Forums
Forum List  »  PHP

Get "Row Number" of a specific record?
Posted by: Haider Zainy
Date: May 17, 2005 01:49PM

I have a table where records are added and removed at all time (via a web/php app). I do have an auto_increment column that gives each record a unique incremental id. But, that sequence get's screwed up when records are deleted.

When I select a record, I'd like to find out what the current row number it's currently at. Does that make sense? Is it possible?

For example, I have the following five records in a table. If I select Record 3, I know it's the third record down from the auto_increment column I have setup.
Record 1
Record 2
Record 3
Record 4
Record 5

But, if Records one and/or two are deleted, "Record 3" is now actually the first or second record down. I'd like very much to find out what position Record 3 is now in. Any way to do this in my php script/sql query?

Relatively new to this stuff. Any info would be greatly appreciated.
Thanks, Haider

Options: ReplyQuote


Subject
Written By
Posted
Get "Row Number" of a specific record?
May 17, 2005 01:49PM


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.