RE: [PHP-DB] easy db question

From: Date: Mon, 02 Apr 2001 22:37:08 +0000
Subject: RE: [PHP-DB] easy db question
Groups: php.db 
Request: Send a blank email to php-db+get-8155@lists.php.net to get a copy of this message
joseph, This was a feature that was recently modified. Older versions of mySQL support the feature that you seem to want. 3.23.xx and above will support the feature that you have just described. If you want to roll your own out, you could do something like... mysql> SELECT IFNULL(MAX(field) , 0) + 1 AS 'Auto Increment' FROM newsStories; +----------------+ | Auto Increment | +----------------+ | 1096 | +----------------+ 1 row in set (0.01 sec) Now let's say that you have a hundred records with an "ID" field enumerated from 1-100. If you went ahead and deleted 51-78, would you try to "reclaim" 51-78? or just continue from 100? If you continue from 100, then the previous query should work. Should you try to "reclaim" 51-78, that seems like a major hassle and I'd probably avoid it at all costs. HTH/my $0.02 chris -----Original Message----- From: Paulson, Joseph V. "Jay" [mailto:jay.paulson@viatel.com] Sent: Monday, April 02, 2001 2:46 PM To: php-db@lists.php.net Subject: [PHP-DB] easy db question hello everyone- I'm running MySQL 3.23.27-beta with php 4.04pl1. What I am wondering is I have an auto incrementing field and if I delete all the entries in the table with this field the incrementing doesn't start over. For example, if I insert 6 records for the first time into this table the auto incremenator gets set to 6 for the last position. Now, if I go and delete all 6 of these entries and then insert 6 more after the deletion the auto incrementing starts off at 7 and goes through 12. I'm just curious if there is a way around this so that if all the records are deleted the auto incrementing field will start back at 1. Thanks, Jay Paulson Developer, Web Technologies Viatel, Inc. http://www.viatel.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#8155) next »