开发者

how do i insert foreign keys in phpmyadmin

i need some help understanding something with php, mysql and phpmyadmin. im sorry if this is the wrong place to ask this, but i dont know where else to ask it.

i have 2 tables, one is the parent table and it has just 2 rows with the indexes 1 and 2, and the second on is the child table and it has a foreign key constraint that relates to the id filed in the parent table. when i wanted to insert data in the child table using phpmyadmin, in the foreign key filed i am allwoed to enter 4 values that are given to me in a drop down list, but i dont understand what they mean because these values have dashes in front of them and after like in the image:

how do i insert foreign keys in phpmyadmin

what do those dashes mean? and what does it mean if they are after or before?

and my second question is, if i insert data into the child table can i use a normal SQL query like this

  INSERT INTO table(f_key) VALUES("for开发者_JAVA百科eign_key_value")

or do i have to use dashes somewhow?

thank you, and im sorry again if i am asking this in the wrong place.


The dashes are confusing, but you can find an answer here: http://qchem.knu.ac.kr/mysqladmin/Documentation.html#faq6_21

In short, they are supposed to represent two different ways of pairing the key and the "display field" so that if you had a large number (but less than 200) you could start typing either the key or the display field and have the right selection come up (i.e. if you knew the foreign key was "2" you could type "2" and "2-" would come up. If the display field was there (the other have of the dupul), you could type its first character and have the same key come up.

The issue, I suspect is that "display field"--I don't know what that's supposed to be. It is always blank in my case.


YOu can just insert the values as you wish. What phpmyadmin means with the dashes is completely unknown to me, but you can basicaly ignore them. So if you want '2', it show up as -2 or something weird. that's a phpmyadmin 'feature'.

In a query you would just use '2'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜