I am trying to wrap my head around this and i have searched google and im not sure how to go about it.
I have a table called Affiliates. In this table i have 3 fields
+---------+-----------------+-------+
| user_id | AffID | total |
+---------+-----------------+-------+
| 1 | Aff1 | 10|
| 2 | Aff1 | 10|
| 3 | Aff2 | 5 |
| 4 | Aff2 | 5 |
+---------+-----------------+-------+
I want to echo out the following results :
Aff1 20
Aff2 10
As you can see it grouped the AffID and added the total value.
Now if i add another affiliate to the AffID for example AffID3 with a total of 10 , it must automatically just display it.
Aff1 20
Aff2 10
Aff3 10
I know i need to use groupby for the AffID , and Sum to calculate the total, but how would i echo out the results ? (in a loop?)