Darkmatter5 Posted December 3, 2008 Share Posted December 3, 2008 I have 3 tables Cabinets cabinet_id cab_name Folders folder_id fol_name cabinet_id Items item_id item_name folder_id Here's some sample data in each table: Cabinets: 1, cab1 2, cab2 3, cab3 Folders: 1, fol1, 1 2, fol2, 1 3, fol3, 2 Items: 1, item1, 1 2, item2, 2 3, item3, 3 4, item4, 1 Now I need to make a query that will list all items from Items that are ultimately within a specific Cabinet. Example.. 1. item1 is in fol1 which is in turn in cab1 2. item2 is in fol2 which is in turn in cab1 3. item4 is in fol1 which is in turn in cab1 So how can I list all items ultimately in cab1 or cab2 or cab3. I know I have to use a JOIN, but I'm not sure how. Quote Link to comment https://forums.phpfreaks.com/topic/135369-solved-help-with-constructing-my-query/ Share on other sites More sharing options...
rhodesa Posted December 3, 2008 Share Posted December 3, 2008 try SELECT * FROM items i, folders f, cabinets c WHERE i.folder_id = f.folder_id AND f.cabinet_id = c.cabinet_id AND c.cab_name = 'cab1' Quote Link to comment https://forums.phpfreaks.com/topic/135369-solved-help-with-constructing-my-query/#findComment-705094 Share on other sites More sharing options...
Darkmatter5 Posted December 3, 2008 Author Share Posted December 3, 2008 worked like a charm. Thanks friend! Quote Link to comment https://forums.phpfreaks.com/topic/135369-solved-help-with-constructing-my-query/#findComment-705141 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.