Jump to content

[SOLVED] Double Join


scottybwoy

Recommended Posts

I have a query :

SELECT p.products_id, p.products_model, p.products_image, p.products_price
FROM products p INNER JOIN products_to_categories ptc
ON ptc.products_id = p.products_id
WHERE ptc.categories_id = " . $n_cat_row['categories_id'] . "
AND p.products_status = 1
ORDER BY p.products_ordered DESC LIMIT 1

 

Can I also get data from another table `products_description`.  In this table it has the columns `product_id`, `products_name` and `language_id`.

 

So I want to pull `products_name` ON `products_id` WHERE `language_id` = LANGUAGE_ID.

 

How do I go about integrating that into my original query?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/124960-solved-double-join/
Share on other sites

Like :

SELECT p.products_id, p.products_model, p.products_image, p.products_price, pd.products_name
FROM products p INNER JOIN products_to_categories ptc
ON ptc.products_id = p.products_id INNER JOIN products_description pd
ON pd.products_id = p.products_id
WHERE ptc.categories_id = " . $n_cat_row['categories_id'] . "
AND p.products_status = 1
AND pd.language_id = " . (int)$languages_id . "
ORDER BY p.products_ordered DESC LIMIT 1

?

Link to comment
https://forums.phpfreaks.com/topic/124960-solved-double-join/#findComment-645680
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.