the position of a record depend on the sort order you choose in your queries
(generally order by) and the execution plan of them.
this execution plan depends on data, indexes, and the query itself. So what you
call order is candidate to changing between two selects.
the method shown with @row++ is a solution, but the given order is the display
data order for you. use an order by so make it stronger.
Selon Jigal van Hemert <jigal@stripped>:
> From: "Ed Reed"
> > Is there way to return the ordinal position of a value within a table?
> > Let's say I have a table of phone numbers. Over time the table has had
> additions and deletions. The table has an autonumber ID field. If I sort by
> the ID field I'd like to know what position the number '555-1212' is in the
> I'm not sure why you'd want to know this, but it's generally a good idea to
> abandon the thought that records in a database are stored in a certain order
> with a position number attached to them.
> The internal way of storing data differs from engine to engine and you can
> never be sure that these internals will not be modified in newer releases of
> It's best to think of a table as a collection of records which can be
> presented in the way you want. The way the database decides to store the
> data is in many cases not relevant at all; that's the job of the database.
> Regards, Jigal.
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=1