Re: ID based on position?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Auugh!!  Why would you want to do this? You're flying in the face of
> relational database theory and practice. Position of a record in the table
> is, or should be irrelevant.

Agreed - "position" is a notional concept. The data is stored physically in
some sort of order, but what order that is is the database's business, not
yours. It could be subject to change when upgrading, and it is very likely
to differ on different platforms or RDBMSs.

You should also be aware that unless you use an order by clause in your
select statement, you don't have a guarantee that all RDBMSs will return the
records in the same row.

I don't know exactly what you want to do, perhaps you can provide more
details?

>
> What if you have twenty thousand records, or two hundred, and the 45th
> record in the table is deleted? Fetching an ID from anything beyond that
> record, based on the order of insertion (position), is instantly broken.
>
> Please rethink what you want to do, and if you are not familiar with
> relational databases read some of the excellent tutorials available on the
> 'Net about them and their design. It's pretty straightforward, common
sense
> stuff -- but you can back yourself into an awkward corner.
>
> Regards - Miles
>
>
> At 07:54 PM 8/31/2005, Gustav Wiberg wrote:
> >Hi there!
> >
> >Is there any function in PHP that gives an ID from a MySQL-db based on
> >which position the record has in the table?
> >
> >
> >Let's say, there's a table like this:
> >
> >1. Record1 ID 33
> >2. Record2 ID 76
> >3. Record3 ID 100
> >
> >
> >If I know position 2, I want to get ID 76. Is the only way to loop
through
> >the recordset?
> >
> >/G
> >@varupiraten.se
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> >

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux