0

I'm using phpMyAdmin (PHP & MySQL) and I'm having a lot of trouble linking the tables using foreign keys.

I'm getting negative values for the field countyId (which is the foriegn key). However, it is linking to my other table and cascading fine.

When I go to add data there will be a drop selection for the CountyId and the values will look something like this:

" -1

1- "

Here is my alter statement:

ALTER TABLE Baronies
 ADD FOREIGN KEY (CountyId)
 REFERENCES Counties (CountyId)
 ON DELETE CASCADE
0

2 Answers 2

1

It is not negaitve number, the feature of phpMYAdmin is to show foreign key value and a custom description field next to it. In the referenced table (Counties) you can go to "Relation view" and under the table there is a select box "Choose field to display", in which you choose value that will be displayed next to CountyID value in the referencing table (Baronies). Also see: phpymadminWiki where it says

6.21 In edit/insert mode, how can I see a list of possible values for a column, based on some foreign table?

You have to setup appropriate links between the tables, and also setup the “display column” in the foreign table. Then, if there are 100 values or less in the foreign table, a drop-down list of values will be available. You will see two lists of values, the first list containing the key and the display column, the second list containing the display column and the key. The reason for this is to be able to type the first letter of either the key or the display column.

More specifically:

The reason for this is to be able to type the first letter of either the key or the display column.

0

I'm using 3.3.2deb1 version and "Choose field to display" doesn't appear.

You must log in to answer this question.