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


Good! How about three exercises for consolidating our knowledge?


Show the name of each treatment and the first and last names of the patients to whom it was recommended for all therapies recommended by physicians with the surname Core or Calderwood.

Consider only patients with odd ID numbers.

Stuck? Here's a hint!

To filter patients' IDs by odd numbers, you can of course take a look at the Database to check the ID's manually and use the IN operator in the following manner:

WHERE IN (1, 3, 5 ... 15)

However, there is also a more concise way to do this. When dividing an odd number by two, the remainder is always 1.

Use the MOD() (modulo) function to find the remainder after division of one number by another. The use of the modulo function in this exercise is as follows:

WHERE MOD(, 2) = 1


FROM therapy
JOIN physician
  ON physician_id =
JOIN patient
  ON patient_id =
JOIN treatment
  ON treatment_type = treatment.type
WHERE physician.last_name IN ('Core', 'Calderwood')
  AND MOD(, 2) = 1