Explanation:
Duplicate entry ‘… ‘For key ‘PRIMARY, the PRIMARY key data to be inserted into the data. It already exists. You can’t add it again. Example: Duplicate entry ‘0’ for key ‘PRIMARY refers to the data with a PRIMARY key value of 0 already exists, so the data with a PRIMARY key value of 0 can no longer be inserted.
Problem Solving:
Before the insert operation, you can perform the search operation SELECT for the primary key value, such as:
Perform an insert (0, “triple”) operation
insert into table(id,name) values(0,'Mr Three');
Duplicate entry ‘0’ for key ‘PRIMARY
can be added a judgment before insertion. If the PRIMARY key value is 0, it can be found, and it exists. If it cannot be found, the insert operation is performed.
select id from table where id = 0;
Read More:
- Error creating foreign key in MySQL: 1215 cannot add the foreign key constraint
- MYSQL Index Key Length 1071 – Specified key was too long; max key length is 3072 bytes
- Hive install initialization error: Error: Duplicate key name ‘PCS_STATS_IDX‘ (state=42000,code=1061)
- Cannot resolve classpath entry: e://jar/mysql-connector-java-5.1.17-bin mybatis error in reverse engineering
- [Solved] EOS7.6 Error: Init DB failed [Specified key was too long; max key length is 767 bytes…
- Mysql Flashback Warning: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe
- [Solved] dynamic-datasource can not find primary datasource
- [Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2)
- [Solved] MYSQL Command Execute Error: Can ‘t connect to local MySQL server through socket ‘/tmp/mysql.sock ‘(2) “
- MySql Install Error: Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
- MYSQL Insert Data Error: check the manual that corresponds to your MySQL server version for the right syntax
- How to Solve can‘t connect to local mysql server through socket ‘/var/lib/mysql/mysql.sock‘
- SQL Server Deletes a table foreign key constraint Error [Solved]
- (Fixed) workbench MySQL Error Code: 2013. Lost connection to MySQL server during query
- MySQL Install Error: MySQL error 1042: Unable to connect to any of the specified MySQL hosts
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’
- [Solved] CentOS installs MySQL and starts MySQL with error 2002 (HY000)
- MYSQL 5.7 Error Code: 1290. The MySQL server is running with the –secure-file-priv option so it..
- MYSQL Enter password:ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost:3306‘
- mac brew install mysql ‘/tmp/mysql.sock’ (2) [How to Solve]