Hi all.  I'm having a little trouble with this query.

**Table 1 (Orders) **

OrderID             SmallInt
OrderStatus               VarChar(20)
CustomerPhone     VarChar(10)
SalesRepID                SmallInt(11)

**Table 2 (Customers)**

CustomerFirst     VarChar(20)
CustomerLast        VarChar(20)
CustomerPhone       VarChar(10)

**Table 3 (SalesReps)**
SalesRepID          SmallInt(11)
SalesRepFirst     VarChar(20)
SalesRepLast      VarChar(20)


I'm trying to retrieve all ORDERS with the CustomerFirst and CustomerLast
and the SalesRepFirst and SalesRepLast from these respective tables.  There
are other fields and they are listed in the SQL statement below.  The ODBC
driver informs me that there is a problem with the JOINS.  I'm very new to
MySQL syntax.  Can  you join more than one table?


SELECT DISTINCT deliverycustomers.CustomerFirst,
            deliverycustomers.CustomerLast,
deliverycustomers.CustomerAddress1,
            deliverycustomers.HouseNumber, orders.OrderID,
servers.ServerFirst,
            servers.ServerLast, deliverycustomers.CustomerPhone,
orders.OrderTime
FROM
                servers INNER JOIN deliverycustomers INNER JOIN orders ON
            deliverycustomers.CustomerPhone = orders.CustomerPhone ON
servers.ServerID =
            orders.DriverID GROUP BY deliverycustomers.CustomerFirst,
            deliverycustomers.CustomerLast,
deliverycustomers.CustomerAddress1,
            deliverycustomers.HouseNumber, orders.OrderID,
servers.ServerFirst,
            servers.ServerLast, deliverycustomers.CustomerPhone,
orders.OrderTime
WHERE
            Orders.OrderType = 'Delivery' AND (Orders.OrderStatus = 'Open'
OR                              Orders.OrderStatus = 'PreAuth') ORDER BY OrderTime;



Any help would be greatly appreciated.
Lee Jenkins


---------------------------------------------------------------------
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