I have three tables: orders, salesmen and customers.
In orders table are SalesmanGroup and SalesmanId,
CustomerGroup and CustomerId fields but not
SalesmanName or CustomerName.
I wish to create a query that returns all fields from
orders but also SalesmanName and CustomerName, which
reside in the salesmen and customers tables.
This query returns three rows for each row in orders.
Not good. What's wrong? How do I fix it?
salesmen.name AS salesmanname
customers.name AS customername
orders.date >= '1999-01-01' AND
orders.date <= '1999-01-07' AND
orders.category = 3 AND
salesmen.salesgroup = orders.salesgroup AND
salesmen.salesmanid = orders.salesmanid AND
customer.customersgroup = orders.customersgroup AND
customer.customerid = orders.customerid