I've got a db with 3 tables - products, products_description and accessories.
The accessories table contains 2 columns:
main_product_id
acc_product_id
If a product has accessories these can be found by performing a right join on the accessories table:
This works fine for locating the accessories for a single product.
However, I now need to be able to find the accessories for a range of products and I don't know how to modify the query.
Can anyone help?
Thanks in advance.
The accessories table contains 2 columns:
main_product_id
acc_product_id
If a product has accessories these can be found by performing a right join on the accessories table:
Code:
select
p.products_id,
pd.products_name,
pd.products_description,
p.products_model,
p.products_quantity,
p.products_image,
pd.products_url,
p.products_price,
p.products_tax_class_id,
p.products_date_added,
p.products_date_available,
p.manufacturers_id
from
TABLE_PRODUCTS p,
TABLE_PRODUCTS_DESCRIPTION pd
right join TABLE_ACCESSORIES pa
on (
p.products_id = pa.sub_product_id
and
pa.main_products_id = $product_id
) where
p.products_status = '1' and
pd.products_id = p.products_id and
pd.language_id = '$languages_id'
This works fine for locating the accessories for a single product.
However, I now need to be able to find the accessories for a range of products and I don't know how to modify the query.
Can anyone help?
Thanks in advance.