MySQL Forums
Forum List  »  Newbie

Dumping results into a temporary table
Posted by: David Kagiri
Date: June 28, 2005 01:32AM

Hi everbody

i would like to dump the results to a temporal table. the query below gives me an error
at 'select sum(total) from temp01'

#Create temporary table containing the results from each of queries
create temporary table if not exists temp01(`Total` float(8,2) default '0.00')

SELECT sum(consultation)+ sum(laboratory) AS total FROM nairobi,familymembers WHERE
familymembers.dependantid = nairobi.memberid and familymembers.memberid = "AKI100000001"
UNION
SELECT sum(consultation)+ sum(laboratory) AS total FROM rift,familymembers WHERE
familymembers.dependantid = rift.memberid and familymembers.memberid = "AKI100000001"
UNION
SELECT sum(consultation)+ sum(laboratory) AS total FROM coast,familymembers WHERE
familymembers.dependantid = coast.memberid and familymembers.memberid = "AKI100000001"

#Sum the totals from the different tables.
select sum(total) from temp01;

#Drop the temporary table.
drop table if exists temp01;

Any solutions to this problem?

Thanks in advance

Options: ReplyQuote


Subject
Written By
Posted
Dumping results into a temporary table
June 28, 2005 01:32AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.