Say I have the table structure as seen below:
food_descriptions
-------
food_id
description
nutrient_data
-------
nutrient_id
food_id
nutrient_value
Example: Say I want to get the total weight of carbohydrates present where food_id = 888 I would do something like:
SELECT food_descriptions.description, nutrient_data.nutrient_value
FROM food_descriptions, nutrient_data, weight
WHERE food_descriptions.food_id = '888' AND food_descriptions.food_id = nutrient_data.food_id AND nutritional_data.nutrient_id='carb'
That will give me the weight of carbohydrates for 100g of food 888 (all nutrient vaues are lister per 100g). If I wanted to get the protein and fibre weight as well, how would I do it, without creating three seperate SQL queries for each nutrient? I want to do it as a single query to cut back on the number of times I'm querying the database and creating an overhead. This isn't so bad when you're dealing with one food source, but if I want the values for over 100 food sources, then querying the database 3 times for each of them is out of the question.