List:General Discussion« Previous MessageNext Message »
From:mfatene Date:June 18 2005 2:19pm
Subject:Re: Ordinal number within a table
View as plain text  
hi,
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.

Mathias

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
> table.
>
> 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
> MySQL.
>
> 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
>
>


Thread
Ordinal number within a tableEd Reed18 Jun
  • Re: Ordinal number within a tableDan Nelson18 Jun
  • Re: Ordinal number within a tableJigal van Hemert18 Jun
    • Re: Ordinal number within a tablemfatene18 Jun
Re: Ordinal number within a tableNishikant Kapoor28 Jun
  • Re: Ordinal number within a tablemfatene28 Jun
RE: Ordinal number within a tableNishikant Kapoor28 Jun
  • RE: Ordinal number within a tablemfatene28 Jun
    • Re: Ordinal number within a tableMichael Stassen29 Jun
      • Re: Ordinal number within a tableMathias29 Jun