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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.