Ok, first of all, I am going to change the name of the tables, fields and values, I am just keeping the structure of my data base for you to understand.
Now, let's suppouse I have a table people, with the fields, id, age, country and language. And another table foods with the food each person in table people ate, fields: person_id, food, units.
Note: food is char, not the ID of another table and I can't change this structure.
Now, let's put some data:
.
People
ID | AGE | COUNTRY | LANGAGE
1 | 25 | usa | en
2 | 46 | mex | es
.
Foods
ID | PERSON_ID | FOOD | UNITS
1 | 1 | apple | 2
2 | 1 | grape | 24
3 | 1 | pizza | 1
4 | 2 | apple | 3
5 | 2 | pizza | 2
.
Fine, what I need is to get the id, age, country and the sum of the apple and grape eaten by a person (ignoring pizza). In this example, if I look for ID 1, I should get:
ID | AGE | COUNTRY | UNITS
1 | 25 | usa | 26
And for ID 2:
ID | AGE | COUNTRY | UNITS
2 | 46 | mex | 3