Re: Question: Correcting MySQL's ID colomn when removing an entry

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

 



On Sun, 2009-09-20 at 01:06 -0700, Lars Torben Wilson wrote:
> On Sun, 20 Sep 2009 12:07:39 +0430
> "Parham Doustdar" <parham90@xxxxxxxxx> wrote:
> 
> > Hello there,
> > I'm guessing that when a row in a MySQL table is removed, the ID
> > colomns of the rows which come after that row are not changed. For
> > example: 1 2
> > 3
> > 4
> > 
> > Now, if I want to remove the third rows, the ID colomn would be
> > something like: 1
> > 2
> > 4
> > 
> > I was wondering if there was a way to fix it through a query, so I
> > wouldn't have to use a for statement in PHP to fix it?
> > 
> > Thanks!
> > 
> 
> I'm not sure why you would want to do that--it would make things very
> hard to keep track of. Once an ID has been assigned to a set of data,
> that ID should not change.
> 
> Perhaps if you explained the actual problem you're having, instead of
> how you're trying to solve it, it would be easier to offer a possible
> solution. There is likely a way to solve it which does not involve
> mangling the stored data.
> 
> 
> Regards,
> 
> Torben
> 

Yeah, the idea of using relational databases like MySQL is so that you
can use multiple tables to store information, and link them by a common
field, often an id. If you go aorund altering your id's so that they run
in order, then you lose any links you had on them that use that field.
There is no reason to have them all run in order anyway, unless you're
writing some really bad queries.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
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