php - I want to make a sum from 5 tables that have one column named "UP"

180

I have 5 tables (bepd , tirpd , elpd , frpd , kopd) with the same column named "Up" , and i want to make the sum of Up from all tables and to show it in a php code . can anyone help me ?

13

Answer

Solution:

select  sum(SumUp)
from    (
        select  sum(up) as SumUp
        from    Table1 
        union all
        select  sum(up)
        from    Table2
        union all
        select  sum(up)
        from    Table3
        union all
        ...
        ) SubQueryAlias

People are also looking for solutions to the problem: php - Opencart: admin category list display by user_id

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.