I have 3 tables:
Group, Person and Workout. Group is a foreign key to Person, and Person is a foreign key to Workout.
I want to select the list of all the people in a certain group, and if there was a workout between the given dates for that person, then also get the duration, if not, just make it null.
Not quite sure how to write the SQL, I'm stuck in something like this:
SELECT Person.id, Person.firstName, Workout.duration
FROM Person LEFT OUTER JOIN Workout
ON Person.id = Workout.person_id
WHERE Workout.start_date BETWEEN %s AND %s
AND Person.group_id = %s
Any ideas?