Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 27th, 2004, 12:46 PM
Friend of Wrox
Join Date: Jun 2003
Location: South Bend, Indiana, USA.
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default Make an existing field auto_increment

I have a table that I got deleted. I remade the table and populated it by hand, but to add new data I need one of the fields to be an auto_increment field how do I set that field to auto_increment since it now has data in it that I need to keep those values.

describe MY_categories;
| Field | Type | Null | Key | Default | Extra |
| cat_id | int(4) | | PRI | NULL | auto_increment |
| parent_id | int(4) | YES | | NULL | |

I need the cat_id to be made to auto_increment, but I do have numbers in that field allready (the ones I had to add by hand).
Reply With Quote
  #2 (permalink)  
Old April 6th, 2004, 04:08 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts


Just fill in the number for the last highest integer.

From the MySQL manual:

: )

The Spicy Peanut Project
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Output existing value to new field Neal SQL Server 2000 5 March 12th, 2007 09:51 AM
SQL script auto_increment vickr1z MySQL 3 January 22nd, 2007 08:22 AM
how to make a query from an existing query raport SQL Language 3 November 13th, 2006 08:59 PM
Make user entered field an integer sswingle Classic ASP Basics 4 April 10th, 2006 10:09 PM
MySQL AUTO_INCREMENT field fcamilo Beginning PHP 1 August 21st, 2003 06:29 PM

All times are GMT -4. The time now is 11:04 PM.

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