Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
Register
| 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 6th, 2005, 01:32 PM
Registered User
 
Join Date: Jul 2005
Location: , , Argentina.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Auto_incremente

Hi! i have a table called Estados and row called EstadoID (int), Description (varchar)

it has 3 records loaded. Now i want to make it auto_increment (EstadoID) because it wasn´t but i receive the error duplicate entry key. How can i make it auto_increment without the need to delete records or updating them (because they are foreigns keys). The problem it´s that i forgot to tell mysql that EstadoID was auto_increment
Thanks in advance. Guillermo.

Reply With Quote
  #2 (permalink)  
Old July 6th, 2005, 01:47 PM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Guillermo,

Something like this should do it...
Code:
ALTER TABLE Estados MODIFY COLUMN EstadoID INT AUTO_INCREMENT;
HTH,

Chris

Reply With Quote
  #3 (permalink)  
Old July 7th, 2005, 08:22 AM
Registered User
 
Join Date: Jul 2005
Location: , , Argentina.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No.... mysql says
Duplicate entry '1' for key 1

This is the content of Estados table

Descripcion EstadoID Imagen
RESERVADO 0 98148-750098490_cartel_raulMel.jpg
Sin Estado 1 59259-685750268_notavailable.JPG
Vendida 2 90741-685750269_notavailable.JPG


Reply With Quote
  #4 (permalink)  
Old July 7th, 2005, 08:42 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

You should not have a zero value in an AUTO INCREMENT column.

Reply With Quote
Reply


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




All times are GMT -4. The time now is 08:24 AM.


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