Forums

PHP

This topic is locked

querying relationship databases

Posted 03 Oct 2006 19:18:38
1
has voted
03 Oct 2006 19:18:38 Tracy Sweder posted:
Hello,

I have 3 tables in a database that all interrelate to one another. I have figured out how to query two at the same time - but now I'm trying to add a 3rd.

So far we have "SELECT * FROM products, rprice WHERE products.ID = rprice.ID ORDER BY products.ID ASC, rprice.ID"

This allows me to retrieve multiple listings of size and price information from the rprice table for the product name and description in the products table.

Now I have a 3rd table, packs, which is a listing of package deals when you purchase multiple products together from the products table. So - I created a pID field in both the packs table and the products table. pID is the key field in packs, and is a foreign field in products and they are linked together as a relationship database.

So - I need to be able to basically tell the page, through PHP, to do this:

Get Product Name from Products one time(done)
Get Product Description from Products one time(done)
Get all Size and Price information for above product from rprice (repeated as needed) (done)
Get package deal information from packs if pID in product above is = pID in packs - list it only one time (NEED TO FIGURE OUT)

Does anyone out there feel like taking a shot at how to do that last item? Do I change my existing recordset query string to include the packs database, and if so how, or do I need a separate recordset? If I do need a separate recordset, is there a way to SELECT * from packs and only SELECT pID from products since I already have * from products selected in the first recordset?

Thanks guys!

Reply to this topic