Issue
I'm writing an android application which sends a particular value of carbohydrates,proteins and fats to the server. My database contains food items which also mentions the amount of carbohydrates, proteins and fats contained in those food items.
I would like to know how to query the database to return the food items which have the values similar to that sent by the app.
ex: Suppose the app sends carbohydrates,proteins and fats as 30,40 and 50 gm to the server. Then the server should extract and send back food items which has carbohydrates in the range of 29-31, proteins in the range of 39-41, fats in the range of 49-51
The food table has list of food items and the columns are of carbohydrates, proteins and fats
From the example I need to get the similar food items i.e brown bread,white bread and almond.
Solution
Try this:
SELECT * FROM Breakfast
WHERE ? between carbohydrate_m - 1 and carbohydrate_m + 1
AND ? between protein_m - 1 and protein_m + 1
AND ? between fat_m - 1 and fat_m + 1
Answered By - Gurwinder Singh
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.