romio Posted March 3, 2006 Share Posted March 3, 2006 well am a bit confused, my database should include many categories and each category could have one or more product, i have designed both of my tables, but how will i proceed now, how do i join them....[code]CREATE TABLE categories( categoryID int(11) NOT NULL auto_increment RIMARY KEY, name varchar(255) default NULL, parent int(11) default NULL, products_count int(11) default NULL, description text, picture varchar(30) default NULL, products_count_admin int(11) default NULL);[/code][code]CREATE TABLE products ( productID int(11) NOT NULL auto_increment PRIMARY KEY, categoryID int(11) default NULL, name varchar(255) default NULL, description text, customers_rating float NOT NULL default '0', Price float default NULL, picture varchar(30) default NULL, in_stock int(11) default NULL, thumbnail varchar(30) default NULL, items_sold int(11) NOT NULL default '0', big_picture varchar(30) default NULL, enabled int(11) NOT NULL default '0', brief_description text, list_price float default NULL, product_code varchar(25) default NULL );[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4002-linking-my-tables/ Share on other sites More sharing options...
Barand Posted March 3, 2006 Share Posted March 3, 2006 Something like this[code]SELECT c.name, p.productID, p.name, p.description, p.priceFROM products pINNER JOIN categories c ON p.categoryID = c.categoryIDORDER BY c.name, p.name[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4002-linking-my-tables/#findComment-13972 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.