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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.