Duplicate values in column that is foreign key

Asked

Viewed 304 times

0

When trying to insert a new data into a given table (employee), I have a column called "manager ID" which is FK from the table itself "employee".

During the registration I send the ID of another employee in this column, only it is returning that I already have the value registered in the column. And I do, but it’s not meant to be. Because I have a column that performs the same function called "empresaID" which is FK too, but from another table, but there is the problem of duplicate values.

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '10' for key 'gerenteID'
  • Index is not blocking duplicate values?

  • You didn’t put the column gerenteID as UNIQUE?

  • I got it handled, guys. Dei um SHOW INDEX FROM 'table' , and then an ALTER TABLE 'table' DROP INDEX 'key'

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.