mysql sub-select work around?

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: David A. Sinck
Date:  
Subject: mysql sub-select work around?

\_ SMTP quoth on 2/5/2003 09:18 as having spake thusly:
\_
\_ Hi Mike,
\_ I think this is what you're looking for.
\_
\_
\_ drop table if exists tmp_idt;
\_
\_ create temporary table tmp_idt
\_ SELECT (idt.unit * idt.price) AS Sub_Total
\_ FROM idt WHERE idt.myid = "1";
\_
\_ select sum(Sub_Total) as 'total' from tmp_idt;

Have we tried the good old

select sum(unit * price) from idt
where myid = 1
?

Seems to work ok for me on my tests.

David