MySQL Forums
Forum List  »  Newbie

Re: Dumping results into a temporary table
Posted by: Paul McArdle
Date: June 28, 2005 04:45AM

create temporary table tmp select 000000.00 as tot;



describe tmp;
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| tot | decimal(8,2) | NO | | 0.00 | |
+-------+--------------+------+-----+---------+-------+

insert into tmp
SELECT sum(consultation)+ sum(laboratory) FROM nairobi,familymembers WHERE
familymembers.dependantid = nairobi.memberid and familymembers.memberid = "AKI100000001"
UNION
SELECT sum(consultation)+ sum(laboratory) FROM rift,familymembers WHERE
familymembers.dependantid = rift.memberid and familymembers.memberid = "AKI100000001"
UNION
SELECT sum(consultation)+ sum(laboratory) FROM coast,familymembers WHERE
familymembers.dependantid = coast.memberid and familymembers.memberid = "AKI100000001" ;

select sum(tot) from tmp;

Options: ReplyQuote


Subject
Written By
Posted
Re: Dumping results into a temporary table
June 28, 2005 04:45AM


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.