tsilenzio Posted July 26, 2007 Share Posted July 26, 2007 Okay i am building a database and it loads the tables with no problems and fills in all the data accept the last one: Tables: // // Table Structure for races // CREATE TABLE races( RaceID INT(2) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, RaceName TINYTEXT NOT NULL, RaceDesc TINYTEXT NOT NULL ); I have the page display every query it does and this is the last 5 lines: INSERT INTO loc (LocID, LocName, LocDesc) VALUES ('0', 'Arnolds', 'Description'); INSERT INTO shops (ShopID, ShopName, ShopLoc, ShopDesc) VALUES ('0', 'Shop', '0', 'Normal Shop'); INSERT INTO races (RaceID, RaceName, RaceDesc) VALUES ('0', 'Causation', ''); INSERT INTO races (RaceID, RaceName, RaceDesc) VALUES ('1', 'African American', ''); Couldnt send query: Duplicate entry '1' for key 1 Any ideas on how to fix this problem? If you are confused then let me know and i will explain as best as i can! thank you in advance!! Quote Link to comment Share on other sites More sharing options...
akitchin Posted July 26, 2007 Share Posted July 26, 2007 primary keys always start with a cardinality of 1 - that is, the value of a primary key for the first inserted record will always be one. therefore your first INSERT into races creates a record with a raceID of 1, and you're trying to insert another one right after it with the same key. if you just drop RaceID from the field and values list, MySQL will take care of assigning it for you. Quote Link to comment Share on other sites More sharing options...
tsilenzio Posted July 26, 2007 Author Share Posted July 26, 2007 ahh ok i get it thought it started at 0 thanx alot! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.