I am relatively new to SQL and have only dealt with very basic statements before.
Table A
- id
- clubid
Table B
- id
- applicationid* (foreign key)id above ^
- n
- p
- k
- mg
- area
What I am trying to do is as follows,
SELECT * from applications WHERE clubid = $id
Then with the result of this I need to run a query along the lines of,
SELECT Sum(n), Sum(p), Sum(k), Sum(mg) from productsapplied where area = $area
I know this second statement is wrong because it would be sum'ing each row which isnt possible so I am trying to find a way to link the two queries together. As I said I am a beginner with this, I have looked up on Sum as well as inner joins but can't get my head around it.
If more details are needed, let me know! Many thanks !