I'm a beginner in programming and would like to know how to add 1-column values into 2 tables, both with the same data. Just change the table name ...
For example:
Table teste1
:
nome | pontos |
Joao | 10 |
Table teste2
:
nome | pontos |
Joao | 10 |
I want it to return like this:
Nome | Total
Joao | 20
I tried to use JOIN
, UNION
, UNION ALL
and I can not ...
I used:
SELECT nome AS nome, pontos AS total from teste1 where nome = 'Joao'
UNION ALL
SELECT nome AS nome, pontos AS total from teste2 where nome = 'Joao'
To which my return is:
nome | total
Joao | 10
Joao | 10
How to return the total of this query : 10 + 10
?