Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Medical Center database
Non primary-foreign key JOINs
6. Exercise 1
Non-equi JOINs
Non-equi self JOINs
Summary

Instruction

Good job! It's your turn to write a query with non primary-foreign key equality.

Exercise

We want to know if there are any patients and physicians who have the same email in our clinic. Perhaps physicians also attend our clinic or former patients were hired by the clinic?

List the first and last name of each patient (name the columns PatientFirstName and PatientLastName) and the first and last name of each physician (name the columns PhysicianFirstName and PhysicianLastName) for patients and physicians who share the same email address.

Stuck? Here's a hint!

Type:

SELECT
  Patient.FirstName AS PatientFirstName,
  Patient.LastName AS PatientLastName,
  Physician.FirstName AS PhysicianFirstName,
  Physician.LastName AS PhysicianLastName
FROM Patient
JOIN Physician
  ON Patient.Email = Physician.Email