![]() ![]() you’ll see that the required query is executed. In the row corresponding to the REFERENCING key, select the REFERENCED key from the second column drop box.Ĭlick go. In the CHILD table’s structure view, click on the link ‘relations view’ (it lies above ‘add fields’). REFERENCED key (in parent) should be primary and REFERENCING key (in child) should be index. I have use simple ajax function call when user select item from select box then it send request to php page and on the basis of selected brand it select product data from product table as per selected brand name. Make sure, both PARENT and CHILD tables are of storage type InnoDB. Both table has one common field which is brand id is a foreign key in product table. Restart mysql from the xampp control panel or from MS services. So InnoDB is disabled in mysql engine, edit the \xampp\mysql\bi\my.cnf file and remove the hashes that are required to enable InnoDB (its self explanatory).Īdd a line in the above file, default_storage_engine=InnoDB (This makes InnoDB the default storage engine). Select any table and go to operations tab, if InnoDB is listed under storage engine drop down menu then jump to step 5. The following steps are required for you to be able to add foreign keys using phpadmin (in xampp). In the row for PID, choose PARENT->ID from the dropdown and click GO.īy doing an export on the CHILD table, you should see a foreign key constraint has been created for the PID column. The first dropdown in each row lets you choose which TABLE->COLUMN the indexed column references. You will be given a table where each row corresponds to an indexed column in your CLIENT table.While viewing the structure tab of the CHILD table, click the "relation view" link just above the "add fields" section.In the CHILD table, define an index for the PID column.Make sure ID is the primary key (or at least an indexed column) of the PARENT table.For both tables, go to the operations tab and change their type to "INNO DB".To setup a foreign key so that the PID column in a table named CHILD references the ID column in a table named PARENT, you can do the following: ![]() ![]() But since, MySQL only supports foreign constraints on "INNO DB" tables, the first step is to make sure the tables you are using are of that type. PhpMyAdmin lets you define foreign keys using their "relations" view. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |