I
I
Ilya Loopashko2020-09-28 07:39:57
MySQL
Ilya Loopashko, 2020-09-28 07:39:57

#1062 - Duplicate record '2-6' for key 'PRIMARY', how to fix?

I'm studying Symfony, and I came across such a problem, the Tag system does not want to work, an error in Mysql, when you add via the Admin panel (EasyAdmin) does not work, if you add it manually via phpMyAdmin, error 1062 crashes, but what's most interesting is the data to be added.

Table structure
5f716b6275139155292872.png

5f716898d8748615833730.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Dokin, 2020-09-28
@alnidok

You made the mistake yourself.
You want to add an entry with post_id=6, tag_id=2, while such an entry already exists in the database.
And it’s still not clear why in the database you have indexes for each column in addition to the composite PrimaryKey. In this case, they are redundant.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question