0

I'm following the instructions in pset7's page, and I have to give users free shares, by inserting a new table in portfolios. However, i get this error:

#1062 - Duplicate entry '1' for key 'PRIMARY' 

here is how my portfolios table is looking: http://imgur.com/jPheoBV

the query i'm using:

INSERT INTO  `pset7`.`portfolios` (

`id` ,
`user_id` ,
`symbol` ,
`shares`
)
VALUES (
'1',  '2',  'FREE',  '10'
)
0

The first field, ID is autoassigned by the database itself and increments automatically. When inserting, don't include that field or a value for it. Let the database assign it.

Further, since ID is the key index, duplicates are not allowed. If there already exists a row with 1 as the ID, it won't allow insertion of another row with the same ID.

BTW, you're inserting a new row in the table portfolios, not a new table.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .