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) 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 Link to comment https://forums.phpfreaks.com/topic/134357-help-with-categorysubcategory-select/#findComment-699833 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.