phpmyadmin and foreign keys

假如想象 提交于 2020-01-13 10:25:08

问题


I added a foreign key constraint to one of my fields.

On insert, the field is showing up as a drop down instead of a text box, as expected.

But the drop down has each value listed twice, once with a minus sign before the value and once with the minus sign after the value.

Like this:

- value1
- value2
- value3
value1 -
value2 -
value3 -

What does this mean?


回答1:


Phpmyadmin by default shows foreign key value and a custom description field next to it (which is set in "Relation view" for the table) separated by hyphen.

See also phpmyadminWiki.




回答2:


As mentioned, pmadb does have to be set up however I found that this is set automatically. What you need to do is:

  1. In the original table go into the relations view and choose which column to display (for example the descriptive name of the row ie: company name)
  2. In the table where you wish to create the foreign key choose the column to display - which is probably going to be an integer ie: (companyID).

When you then go to insert you will find that you can see the both the integer and the corresponding name - ie: 1 - Company name



来源:https://stackoverflow.com/questions/5480859/phpmyadmin-and-foreign-keys

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!