menios Posted November 30, 2007 Share Posted November 30, 2007 Hi I currently have a table with products and another one with categories. the structure is: table_category table_product cat_id(PrimaryKey) pd_id (Primary key) cat_name cat_id(FK) pd_name pd_qty All items in products belong to different categories. Now i want to link each product with a certain category how can i do this? Thanks for any help:) Quote Link to comment https://forums.phpfreaks.com/topic/79572-keys/ Share on other sites More sharing options...
fenway Posted November 30, 2007 Share Posted November 30, 2007 You need a third table with ( pd_id, cat_id ) records. Quote Link to comment https://forums.phpfreaks.com/topic/79572-keys/#findComment-403039 Share on other sites More sharing options...
menios Posted November 30, 2007 Author Share Posted November 30, 2007 Can you be a bit more specific on the structure pls? I create another table and how do i link it? Quote Link to comment https://forums.phpfreaks.com/topic/79572-keys/#findComment-403045 Share on other sites More sharing options...
fenway Posted November 30, 2007 Share Posted November 30, 2007 That's the structure -- two FK fields and probably a UID. You "link" them by insert a record that ties the two existing table records together. Quote Link to comment https://forums.phpfreaks.com/topic/79572-keys/#findComment-403051 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.