PDA

View Full Version : mysql error: Duplicate entry '3' for key 1


Lesane
Sat 9th Feb '02, 11:49am
I have currently 1 row in the table award:

------------------------------------
| awardsid | userid | name |
------------------------------------
| 3 | 10 | lala |
------------------------------------


awardsid = int(5), UNSIGNED, auto_increment

Now i'm trying 2 add another row with the same awardsid but then with an other userid and name:

INSERT into award (awardsid,userid,name) VALUES ('3','12,'lesane')

so i want it like this:

------------------------------------
| awardsid | userid | name |
------------------------------------
| 3 | 10 | lala |
------------------------------------
| 3 | 12 | lesane |
------------------------------------


but then it gives me this error:

mysql error: Duplicate entry '3' for key 1. I understand the error but i wonder if its possible what i want(auto_increment + duplicated entry's), awardsid has 2 be auto_increment.

I hope someone has a solution for my problem. Any help is much appreciated.

jeffct
Tue 12th Feb '02, 2:42am
I don't fully understand your problem but if you have that field set as auto_increment already, you don't need to give it a value when you do an insert, it will create one automatically.

Bane
Tue 12th Feb '02, 10:50am
INSERT into award (awardsid,userid,name) VALUES ('NULL','12,'lesane')

or

INSERT into award (awardsid,userid,name) VALUES ('','12,'lesane')

jeffct
Tue 12th Feb '02, 12:21pm
You mean:

INSERT into award (userid,name) VALUES ('12,'lesane')

Lesane
Tue 12th Feb '02, 1:40pm
Thanks for the replies, i found out that there is no possibility to do what i want.