scarhand Posted November 26, 2008 Share Posted November 26, 2008 i have 3 tables: main_categories (id, name) sub_categories (id, name, main_category_id) listings (id, name, sub_category_id) i want to select all of the listings that are under the "main_category" specified can i get some help? im really terrible at JOINS (if that even what i should use) Quote Link to comment https://forums.phpfreaks.com/topic/134357-help-with-categorysubcategory-select/ Share on other sites More sharing options...
Barand Posted November 26, 2008 Share Posted November 26, 2008 SELECT l.id, l.name FROM listings l INNER JOIN sub_categories s ON l.sub_category_id = s.id INNER JOIN main_categories m ON s.main_category_id = m.id WHERE m.id = $selected_id Quote Link to comment https://forums.phpfreaks.com/topic/134357-help-with-categorysubcategory-select/#findComment-699833 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.