Well, what I need to do is something like this:

select sum(tax) from orders, orderdetail where orders.id =
orderdetail.orderid and (productid = 1 or productid = 2 or productid =
3)

The problem is this that when I run this sql query:

select orderdetail.itemid, orderdetail.id as odid, orders.id, orders.tax
from orders, orderdetail where orders.id = orderdetail.orderid and
(productid = 1 or productid = 2 or productid =
3)

I get something like this:

Itemid  Odid    Orderid Tax     
1               13      1               16.71
2               14      1               16.71
3               15      1               16.71
1               16      2               10.00
1               17      3               15.00

Which leads me to believe that if I take a sum(tax) it will sum all
three.  I only want one record, not all three.

David

-----Original Message-----
From: Michael T. Babcock [mailto:[EMAIL PROTECTED]] 
Sent: Friday, October 04, 2002 2:19 PM
To: David McInnis
Cc: [EMAIL PROTECTED]
Subject: Re: Query help

So you want something like:

SELECT ORDERDETAIL.id as detailid, qty, unitcost, unitcost * qty as 
extended from ORDERDETAIL
    LEFT JOIN ORDERS ON orderid = ORDERS.id;

Right?

What's the problem you have with tax requests that you hinted at last
time?

David McInnis wrote:

>ORDERS
>
>+--------------+---------------------------
>| Field        | Type                      
>+--------------+---------------------------
>| id           | int(10) unsigned zerofill 
>| subtotal     | float(10,2)              
>| tax          | float(10,2)              
>| rushfee      | float(10,2)              
>| total        | float(10,2)              
>
>ORDERDETAIL
>
>+----------------+---------------------------
>| Field          | Type                      
>+----------------+---------------------------
>| id             | int(10) unsigned zerofill 
>| orderid        | int(11)                   
>| qty            | int(11)                   
>| unitcost       | float(10,2)               
>  
>
-- 
Michael T. Babcock
C.T.O., FibreSpeed Ltd.
http://www.fibrespeed.net/~mbabcock




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to