How about:

select sum(t1.column1 + t2.column2 +t3.column3) as Columnsum
from 
Table1 t1
inner join Table2 t2 on t1.id=t2.id
inner join Table3 t3 on t2.id=t3.id
where t1.id=n
group by t1.id

This is a rough cut that assumes the id value  in the join  exists in all 
three tables.  If it's missing in any one of the tables, then the query 
will return null.  If that is not okay, then you'd have to do something 
with outer joins...without knowing what you're trying to find it's hard to 
be more specific.

Donna




"Peter South" <[EMAIL PROTECTED]> 
08/17/2006 05:05 PM

To
<mysql@lists.mysql.com>
cc

Subject
Tables/sum






Can anyone tell me how to add up values in different tables? For example 
Table1.Column1 + Table2.Column2 + Table1.Column3 Where id(row) = n
Thanks
Peter
-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



CONFIDENTIALITY NOTICE:This email is intended solely for the person or 
entity to which it is addressed and may contain confidential and/or 
protected health information.  Any duplication, dissemination, action 
taken in reliance upon, or other use of this information by persons or 
entities other than the intended recipient is prohibited and may violate 
applicable laws.  If this email has been received in error, please notify 
the sender and delete the information from your system.  The views 
expressed in this email are those of the sender and may not necessarily 
represent the views of IntelliCare.

Reply via email to