mysql sub-select work around?

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: plug-discuss@lists.plug.phoenix.az.us
Date:  
Subject: mysql sub-select work around?
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;



hope this helps.
Peter

On 5 Feb 2003 at 10:47, Mike Starke wrote:

> I know the new version of MySQL supports subselects,
> but I am just not ready for that upgrade. So here's my
> question:
>
> I have a table called 'idt' with two columns "unit" and "price".
> How can I get an equivalent SQL statement that will work in
> MySQL 3.23
>
> SELECT SUM
>         (
>     SELECT (idt.unit * idt.price) AS Sub_Total
>     FROM idt WHERE idt.myid = "1"
>     )  AS Total 
>     FROM idt

>
> v/r
> -Mike
> ---------------------------------------------------
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change you mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
>