-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Perhaps:
SELECT o.orderid, c.Customerid, o.EmployeeID, e.LastName
FROM (orders as o INNER JOIN Customers as c
ON o.Customerid = c.Customerid) INNER JOIN Employees As e
ON o.EmployeeID = e.EmployeeID
Table design:
You should have the EmployeeID in the Orders table not in the
Customers table: an order has an employee (who handled the creation
of the order) and a customer (who requested the item). Customers
don't HAVE employees (unless you got something kinky going on). In
the Orders table the EmployeeID should be required, as should the
CustomerID - then you can't have an order w/o the person who requested
it & the person who handled it.
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQEJMC4echKq OuFEgEQLGJwCfW7 J94dOI2G2o4ScG7 atcIcbJoskAnRVM
GNqK13ghXBRhSd2 F3NF+UEnb
=/H0r
-----END PGP SIGNATURE-----
Johm wrote:
In my query, consisting of 2 tables, customers and orders,i get the
employeeid number ordered with a given customer.
The query is the following :
SELECT orders.orderid, Customers.Custo merid, Customers.Emplo yeeID
FROM orders INNER JOIN Customers ON orders.customer id =
Customers.Custo merid;
If i add on another table in the query, the tables Employees, then my
query
doesnt show anything.If i remove the table employes from the query,
then the query is
ok again.Obviously the table employees is not convenient for the
query. I need the table
Employees in order to from there the LastName of the
employee.The tables customers and employees are related one to many,
one employee may have many
customers.
How do you solve such problems with queries ?