Zimbo Posted March 1, 2008 Share Posted March 1, 2008 I'm working on coding a crop selection tool. I've got 2 tables: crop_lut 118 rows -- 4 columns: management_goal, planting_duration, planting_season, crop crop_db 16 rows -- 10 columns: crop, cost, supplier, planting_tips,... A user makes a selection from the crop_lut using any or all of the first 3 categories, crop is not available for them to query. The resulting query (it could be 118 rows if no choice is made) needs to pull the crop data from the crop_db table. As there are only 16 crops that's all that should be displayed. Redundant crop matches from the look up table should be ignored. I've been searching for a solution and have come up empty. The only thing I can think to do is send the results from a query to the look up table through a loop to pull crop matches out, then build a second query to send to the crop db to run those results. Seems like the long way around and though I can make it work I think there must be a better way. Anybody got a recommendation, just looking to be pointed in a direction. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/93859-making-a-selection-from-a-lookup-table-return-values-from-another-table/ Share on other sites More sharing options...
fenway Posted March 1, 2008 Share Posted March 1, 2008 You can simply group by "crop" in your join. Quote Link to comment https://forums.phpfreaks.com/topic/93859-making-a-selection-from-a-lookup-table-return-values-from-another-table/#findComment-480923 Share on other sites More sharing options...
Zimbo Posted March 1, 2008 Author Share Posted March 1, 2008 Thank you, thank you, that worked! I knew there had to be a simple answer. I spent hours yesterday trying to figure this out. I guess I know enough to be dangerous! Quote Link to comment https://forums.phpfreaks.com/topic/93859-making-a-selection-from-a-lookup-table-return-values-from-another-table/#findComment-480962 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.