To filter patients' ID
s 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 patient.id 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(patient.id, 2) = 1
Type:
SELECT
name,
patient.first_name,
patient.last_name
FROM therapy
JOIN physician
ON physician_id = physician.id
JOIN patient
ON patient_id = patient.id
JOIN treatment
ON treatment_type = treatment.type
WHERE physician.last_name IN ('Core', 'Calderwood')
AND MOD(patient.id, 2) = 1