Foreign key in phpMyAdmin brings duplicate record

Asked

Viewed 41 times

0

Problem

I have a table called "entidades_category-script" (let’s call 'A') that has the following keys:

Chaves da TABELA A

It turns out that it references another table called entidades_category-script-type (let’s just call 'B'), which has only the following records:

Registros da TABELA B

Hence, in phpMyAdmin, when I try to insert a new record in table A the following situation happens:

Registros duplicados no campo da chave estrangeira

Therefore

What would be causing SELECT to show in its options TABLE B items in this format? The expected would be "id - name", but it ends up showing "id - name; name - id" or this is a default behavior in phpMyAdmin?

  • Sorry you did not explain what the problem is. Was an error displayed? Maybe a SELECT with the respective result can clarify what the question is.

  • The SELECT you suggested was presented in the third figure of my question. If you check table B, you can see that there are only two entries in it, whereas SELECT shows 6, because it ends up bringing two blank values, in addition to the two reverse pre-registered records (name - id; id - name). The expected result would be only (id - name).

  • I’m sorry you didn’t present the SELECT code and what you say is the result of what I assume would be a JOIN doesn’t seem believable with the data you say exists in the table.

  • But it’s not my application I’m talking about. That image is from phpMyAdmin itself. I didn’t program it. It is accessed via the "INSERT" menu after I click on the desired table. This is a question about the database manager interface.I did not enter any SQL or JOIN statements. I just set up FK as presented.

No answers

Browser other questions tagged

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