scottybwoy Posted September 19, 2008 Share Posted September 19, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/124960-solved-double-join/ Share on other sites More sharing options...
Mchl Posted September 19, 2008 Share Posted September 19, 2008 You can. Add another INNER JOIN after ON ptc.products_id = p.products_id Quote Link to comment https://forums.phpfreaks.com/topic/124960-solved-double-join/#findComment-645677 Share on other sites More sharing options...
scottybwoy Posted September 19, 2008 Author Share Posted September 19, 2008 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/124960-solved-double-join/#findComment-645680 Share on other sites More sharing options...
Mchl Posted September 19, 2008 Share Posted September 19, 2008 Yeah. Should work Quote Link to comment https://forums.phpfreaks.com/topic/124960-solved-double-join/#findComment-645683 Share on other sites More sharing options...
scottybwoy Posted September 23, 2008 Author Share Posted September 23, 2008 No it doesn't I echoed out the statement and the variables are correct, I ran it through phpMyAdmin, and it didn't like it there either. Quote Link to comment https://forums.phpfreaks.com/topic/124960-solved-double-join/#findComment-648510 Share on other sites More sharing options...
Mchl Posted September 23, 2008 Share Posted September 23, 2008 And what did it say? Quote Link to comment https://forums.phpfreaks.com/topic/124960-solved-double-join/#findComment-648513 Share on other sites More sharing options...
scottybwoy Posted September 23, 2008 Author Share Posted September 23, 2008 Sorry my mistake. It did miss one $var that messed it up. Cheers for your help Quote Link to comment https://forums.phpfreaks.com/topic/124960-solved-double-join/#findComment-648529 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.