Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
| Search | Today's Posts | Mark Forums Read
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 5th, 2007, 03:54 AM
Registered User
Join Date: Mar 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Auto increment

Hi all,
  I have a small issue here. i have a table with column as 'id' hav an auto_increment feature. the table has 10 rows. when i delete the 9th row, " delete from myTable where id='9'; . then the 9th row gets deleted. Then the table would be like:

Here the 10th row id is not changing to 9. How can that be done. some one please help.

Thanks in advance,

Old April 6th, 2007, 09:08 AM
Registered User
Join Date: Apr 2007
Location: Belgrade, , Yugoslavia.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to svlada



Stankovic Vlada
Old April 6th, 2007, 04:03 PM
Friend of Wrox
Join Date: Jul 2003
Location: South San Francisco, CA, USA.
Posts: 128
Thanks: 0
Thanked 1 Time in 1 Post

In practice, I don't delete records with auto_increment field.
I usually take note of the ai (auto_increment) value in that field and update
it for a new one or last record. My reasoning is because in a multiuser environment
number of records in a table is usually related to another table.
in your example what I do is update row 10 to 9.
if this won't work make a copy and rename your table, copy the structure only the insert the values excluding the ai field from the copied table.
hope this helps.

Old April 7th, 2007, 05:47 AM
Registered User
Join Date: Mar 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts

Hi John
  Thank you verymuch for ur reply. it gave me an idea.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding auto increment of id Rajesh225 ASP.NET 1.0 and 1.1 Basics 1 June 27th, 2007 05:35 PM
How to auto increment ? Shawn Mohan SQL Server 2000 2 June 22nd, 2006 03:00 AM
How to auto increment? Shawn Mohan ASP.NET 2.0 Basics 6 June 20th, 2006 10:36 PM
Auto-increment using VBScript CraigKornacki VB How-To 1 April 6th, 2004 02:17 PM
auto increment? hosefo81 PHP Databases 1 February 2nd, 2004 03:56 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.