Hmmm... Looks like you over did the query to me. This should work.
SELECT o.OrderID, c.CustomerFirst, c.CustomerLast, s.SalesRepFirst,
s.SalesRepLast
FROM Orders as o, Customers as C, SalesReps as s
WHERE O.CustomerPhone=c.CustomerPhone AND o.SalesRepID=s.SalesRepID
of course you don't need the o.OrderID but I usually like selecting the ID
from the main table being queried.
----- Original Message -----
From: "Lee Jenkins" <[EMAIL PROTECTED]>
To: "MySQL Mail list" <[EMAIL PROTECTED]>
Sent: Monday, January 29, 2001 10:18 PM
Subject: Help with Query Syntax?
>
>
> 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
>
>
>
---------------------------------------------------------------------
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