View Single Post
Old 02-18-2013, 06:10 AM   PM User | #1
Taipan
New Coder

 
Join Date: Mar 2004
Posts: 95
Thanks: 8
Thanked 0 Times in 0 Posts
Taipan is an unknown quantity at this point
Help with Multiple Joins

Hi,

I am not very good building mysql queries using Joins. I hope someone can help me.

I have a table 'products' with id, name and category_id fields. I also have a table 'categories' with id and name fields. I also have a table 'product_extra_categories' which allows a product to be included in a category other than its primary one. It has fields id, product_id and category_id.

I need to display a list of products.id's and the categories.name where the products.category_id = the chosen category number or the product has the chosen category number as an extra category, ie product_extra_categories.product_id = products.id AND product_extra_categories.category_id = categories.id

I have tried many things and keep stuffing it up. Sorry for my poor explanation. Thanks in advance.
Taipan is offline   Reply With Quote