It turns out that I have two tables:
Label and Priority
the fields in the tag table:
id
priority_tag_id
name
image
the fields in the priority table:
id
name
and so are my tables:
And then I execute the following query:
INSERT INTO etiqueta (name, image, priority_tag_id) VALUES ("Spanish", "imagen_tag_spanish",1);
I get this error:
#1062 - Duplicate entry '1' for key 'UNIQ_389B783424F0A6A'
the number 1
that happened to the query is an id of the table Prioridad
, which is an existing row.
It happens like this: When I have the table Etiqueta
is completely empty and I execute the query, I execute it satisfactorily, but when I run it again the same query a second time gives me that error.
Another thing that I realized is that in the column priority_tag_id
of the tag table I can not insert repeated numbers (I think it's because it's foreign, but still I do not understand), image:
Let's say, I can not make a query as it is:
INSERT INTO etiqueta (name, image, priority_tag_id) VALUES ("Spanish", "imagen_tag_spanish",1);
Since I would give error, because the id 1 (foreigner) already exists in that column of the table Etiqueta
.
The question I ask, because that error, if it's just an id from the Prioridad
table and this obviously exists, I really do not understand.