I have 2 tables as
Table 1
-------------------------------
ID | Name | Bottles | Balance
-------------------------------
1 | ABC | 2 | 200
2 | DEF | 5 | 500
3 | GHI | 3 | 100
Table 2
-----------------------------
CID | Add_Bottles | Amount
-----------------------------
2 | 2 | 100
1 | 1 | 50
2 | 3 | 150
1 | 1 | 50
3 | 2 | 100
What I want to get is First get Bottles and Balance from table1 and then add bottles and balance to table2 rows and continue. I mean, for example, the result for CID 2 should be like this
--------------------------------------------------
CID | Bottles | ttlBottles | Amount | Balance
--------------------------------------------------
2 | 0 | 5 | 0 | 500 <-- First Row from table1
2 | 2 | 7 | 100 | 600 <-- Now adding bottles and balance from tabl2
2 | 3 | 10 | 150 | 750
I can't get an idea that what should be my query to do so. What would you suggest?