Re: Auto Increment Problems....

From: Date: Tue, 30 Jul 2002 19:45:51 +0000
Subject: Re: Auto Increment Problems....
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-110409@lists.php.net to get a copy of this message
If you have an auto_increment mysql field, it's supposed to save you the time of computing the "next" ID. the database will handle it for you. Use "0" as the ID for new rows and mysql will automagically compute the next ID. All of this info is on the mysql.com/doc/ site... please check there in the future for MySQL questions -- Scott Hurring Systems Programmer EAC Corporation scott (*) eac.com -- "Georgie Casey" <webmaster@filmfind.tv> wrote in message news:20020729194732.70319.qmail@pb1.pair.com... > rite, > > my primary key column ("id") is set to auto_increment as usual which is very > handy. But when I delete a row, the auto_increment just keeps incrementing > and there's this 'hole' left where I deleted the row! > > Apart from this looking ugly, it poses another problem. In my PHP script > where I can add new rows, I query the table, checking how many rows in the > table altogether and set the new id as the next number, but this doesnt work > if theres 'holes' in the id field, as the new record tries to overwrite > another id. > > So I've 2 questions > 1) Can the next auto_increment value be 'set' by a SQL query???? > 2) Can I get a SQL query to INSERT INTO the first 'hole' it finds in the ID > column?? > > TIA > >

« previous php.general (#110409) next »