Re: Automotive Product Database (Structer & PHP)
Posted by: Andrew Gilfrin
Date: February 28, 2006 11:11AM

What you need is a table in the middle somewhere. So you have for example CAR and PRODUCT, in the middle you need soemthing like CAR_PRODUCT.

On the tables you have some sort of ID so for cars you have CAR_ID and product you have PRODUCT_ID, the CAR_PRODUCT table holds both of these values.

So if you want to see all of the cars which have a particular product you use...

SELECT c.car_id, c.name FROM car c JOIN car_product p ON c.car_id = p.car_id
AND p.product_id = '12345';

...and if you want to see all products for a particular car use...

SELECT p.product_id, p.name FROM product p JOIN car_product c ON p.product_id = c.product_id
AND p.car_id = '12345';

Andrew Gilfrin
------------------
http://gilfster.blogspot.com
My MySQL related Blog

http://www.mysqldevelopment.com
MySQL Stored Procedure,Trigger, View.... (Just about most things these days) Information

Options: ReplyQuote


Subject
Written By
Posted
Re: Automotive Product Database (Structer & PHP)
February 28, 2006 11:11AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.