2
Contributors
2
Replies
17
Views
3 Years
Discussion Span
Last Post by Paor
1

There may be an easier way, but I think this works:

SELECT `name`, SUM(sm) AS total FROM ((SELECT `name`, kns AS sm FROM tab1) UNION ALL (SELECT `name`, kng AS sm FROM tab2)) AS tbl GROUP BY tbl.name

You may benefit from using an user_id in order to relate your tables properly.

0

@diafol
thank you very much, i really appreciate your answer

This is a very simplified example, i just want to learn how to do that

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.