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
- Error 1406 (22001) in MySQL: data too long for column (Fixed)
- [How to Fix]Mybatisplus ignores mapped fields
- Introduction to Relational Databases in SQL
- How to Fix MySQL error 1005: can’t create table (errno: 150)
- The setobject() method reports an error. The parameter index out of range and MySQL syntax error exception report an error
- mysqli_ Error() has no return value (Fixed)
- MySQL 8.0 error 1114 (HY000): the table’sbtest1’is full (Fixed)
- Oracle creates a job and executes the stored procedure with parameters regularly
- SQL Server Group sort de duplication row_ number() over ( PARTITION BY t1.col_ 2 ORDER BY 1 )
- View’s select contains a subquery in the from clause bug
- MySQL automatically creates partitions through events
- Can mybatis prevent SQL injection
- SQL server converts multiple lines into one line, separated by characters
- (Fixed) workbench MySQL Error Code: 2013. Lost connection to MySQL server during query
- ERROR 1265 (01000): Data truncated for column ‘ENABLED’ at row 7
- Error [err] is reported when redirecting_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
- C# System.Data.SQLite.SQLiteException:“SQL logic error or missing database no such table: XX”
- How to Fix MySQL ERROR 1130 (HY000): Host ‘XXXX’ is not allowed to connect to this MySQL server