Jump to content

[SOLVED] Duplicate entry??


yandoo

Recommended Posts

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 :)

Link to comment
https://forums.phpfreaks.com/topic/90067-solved-duplicate-entry/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.