Reputation: 55
I am simply not understanding joins very well at all!
My exercise calls for:
Display the employee’s last name and first name, city, country and ship city for orders where the employees live in the city where the order is delivered.
I have started my answer thus far here:
SELECT
Employees.LastName,
Employees.FirstName,
Employees.City,
Employees.Country,
Orders.ShipCity
FROM
Employees,
Orders
But then I realise that I am stuck and do not know where to go from here. Do I need to find a table that has common entries in both in order to find primary keys and foreign keys? What is my solution here?
For reference, here is an image of where I am taking data from for my solutions:
Upvotes: 0
Views: 244
Reputation: 115
SELECT
Employees.LastName,
Employees.FirstName,
Employees.City,
Employees.Country,
Orders.ShipCity
FROM
Employees inner join Orders
on Employees.EmployeeID= Orders.EmployeeID;
Upvotes: 1