yandoo Posted February 8, 2008 Share Posted February 8, 2008 Hi there, I have 3 tables each table has an auto incremet primary key! The 3rd of the 3 tables holds info which includes all 3 primary keys in a table ... Thats 1 auto increment primary key for that table and 2 other auto increment keys that are primary ones of there own table. My problem is that when i try to insert any other record other than the 1st one ?? i get the eror message: Duplicate entry '2' for key 1... Whats going on????? Any help much appreciated Thanks Quote Link to comment https://forums.phpfreaks.com/topic/90067-solved-duplicate-entry/ Share on other sites More sharing options...
aebstract Posted February 8, 2008 Share Posted February 8, 2008 It would help if we could see your code. Quote Link to comment https://forums.phpfreaks.com/topic/90067-solved-duplicate-entry/#findComment-461813 Share on other sites More sharing options...
pocobueno1388 Posted February 8, 2008 Share Posted February 8, 2008 Every field that is a primary keys means it can never have the same value more than once. Are you positive that your not duplicating the primary key in that table? Quote Link to comment https://forums.phpfreaks.com/topic/90067-solved-duplicate-entry/#findComment-461815 Share on other sites More sharing options...
aschk Posted February 8, 2008 Share Posted February 8, 2008 Assuming your third table takes the following form <pre> 1, 1, 1 2, 2, 1 1, 2, 3 </pre> And you want to represent all combinations of those possible numbers but never (for example, 1,1,1 & 1,1,1) a duplicate. You need to put the primary key index on that table to be a combination of those three fields. Sounds like you're trying to represent a multi-to-multi relationship using an intermediate table. Thus really you table should have 2 columns, being fk1, and fk2, but the primary key for that table consists of both those foreign keys. Quote Link to comment https://forums.phpfreaks.com/topic/90067-solved-duplicate-entry/#findComment-461823 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.