SUM 2 columns with 2 columns same name I have this table id, teama, teamb, pointa, pointb.

Columns teama and teamb containing the same names. I want to output the sum grouped by teama from teama where pointa and where teamb pointb.

for example:

id, teama, teamb, pointa, pointb
1,  aa,    bb,    1,      2
2,  bb,    aa,    2,      1


What  want as result:

aa, 2
bb, 4


I'm really stuck on this one. I'm using MySQL and PHP.
Looks like a list of match results and you want to get won/lost points:

SELECT team, SUM(pointa), SUM(pointb)
FROM
 ( -- use all rows twice with switched points
   SELECT teama AS team, pointa, pointb
   FROM tab
   UNION ALL
   SELECT teamb, pointb, pointa
   FROM tab
 ) AS dt
GROUP BY team