summing column from 3 different tables
Posted: Fri Feb 08, 2013 2:31 am
Helo Guys,
I'm new member here. I just thought Google is enough to solve my problem regarding mysql.
can someone help me out to solve this.
I have 3 tables.
Tbl_1
id-------emID-------days
Tbl_2
id-------emID-------days
Tbl_3
id-------emID-------days
I have script like this.
I want to sum all (days) column from my 3 tables with where clause. how should i do that?
All best!
I'm new member here. I just thought Google is enough to solve my problem regarding mysql.
can someone help me out to solve this.
I have 3 tables.
Tbl_1
id-------emID-------days
Tbl_2
id-------emID-------days
Tbl_3
id-------emID-------days
I have script like this.
Code: Select all
SELECT SUM(days) AS total_days
FROM (SELECT `days` FROM `Tbl_1` WHERE `emID`=0001
UNION ALL
SELECT `days` FROM `Tbl_2` WHERE `emID`=0001
UNION ALL
SELECT `days` FROM `Tbl_3` WHERE `emID`=0001) t
All best!