select from multi tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

I have a situation where I need to get data from more than one table, but where the fields in the table are identical, the two tables are holding data for different years. The queries I would like to execute would be something along the lines of this: -

SELECT SUM(T1.F1) AS C1, SUM(T2.F1) AS C2 FROM T1, T2

Which I would like to give the total of T1.F1 in C1 and the total of T2.F1 in C2.

What I get however is the sum of T1.F1 * sum of T2.F1 in both result fields and the number of records found as being the sum of the number of records in T1 * those in T2.

What I would like to do eventually with this is get the sum of F1 from any number of tables each representing a year as I don't want to lump all my data into one big table that will get out of hand.

Can anyone tell me the right way to go about this?

Cheers

Dan

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux