So my MySQL database is behaving a little bit wierd. This is my table:
Name shares id price indvprc
cat 2 4 81 0
goog 4 4 20 20
fb 4 9 20 20
I'm getting this #1062 error when I try to insert into the table. So I looked into it further and realized that when I try to insert values into the table, in which the name and shares values are the same, it will return the #1062 error. For example, If i inserted:
fb 4 6 20 20
It would return an error. But if i changed the shares number to 6, it would run fine. Is it because of one of my columns that could be unique, or is it just something with mysql?
You need to remove shares
as your PRIMARY KEY
OR UNIQUE_KEY
Use SHOW CREATE TABLE your-table-name
to see what column is your primary key.
PRIMARY KEY
was selected AUTO_INCREMENT
.ALTER TABLE [table name] AUTO_INCREMENT = 1
I solved it by changing the "lock" property from "shared" to "exclusive":
ALTER TABLE `table`
CHANGE COLUMN `ID` `ID` INT(11) NOT NULL AUTO_INCREMENT COMMENT '' , LOCK = EXCLUSIVE;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With