brooksh Posted March 13, 2012 Share Posted March 13, 2012 How can I combine these two queries then how do I display the results? First I need to grab my main category SELECT DISTINCT category_name,category_id FROM db WHERE parent_id ='0' Order By category_name Then I need to grab the subcategories with the $category_id from the main category SELECT DISTINCT category_name,category_id FROM db WHERE parent_id = '$category_id' Order By category_name Link to comment https://forums.phpfreaks.com/topic/258783-how-can-i-combine-these-two-queries-into-one/ Share on other sites More sharing options...
Muddy_Funster Posted March 13, 2012 Share Posted March 13, 2012 you could try SELECT DISTINCT category_name, catagory_id FROM db WHERE parent_id IN (0, (SELECT catagory_id FROM db as dbTemp WHERE parent_id = 0)) Link to comment https://forums.phpfreaks.com/topic/258783-how-can-i-combine-these-two-queries-into-one/#findComment-1326782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.