Created
June 5, 2014 13:57
-
-
Save wunki/b9d3e50a9adc7f6cdde6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- name: fetch-students-for-user | |
-- Returns all the students for this user | |
SELECT * | |
FROM users | |
WHERE id IN | |
(SELECT user_id FROM students WHERE flow_id IN | |
(SELECT id FROM flows WHERE owner_id = :user_id)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wat vind je van deze:
SELECT *
FROM users
WHERE id IN
(SELECT DISTINCT user_id FROM students
LEFT JOIN flows ON flows.id = flow_id
WHERE owner_id = :user_id)