-
-
Save anonymous/04d8539f2dd7a3d27156 to your computer and use it in GitHub Desktop.
This file contains 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
clocks: shift_id | |
shifts: employee_id | |
employee: name | |
hierarchies: inferior_id, superior_id (both link to employee) | |
Want to only return clocks whose associated employee has a hierarchy | |
where their id matches the inferior_id and the superior_id matches 4 | |
or the associated employee's id is 4 | |
SELECT clocks.* FROM clocks | |
INNER JOIN shifts ON shifts.id = clocks.shift_id | |
INNER JOIN employees ON employees.id = shifts.employee_id | |
INNER JOIN hierarchies ON hierarchies.inferior_id = employees.id | |
WHERE (hierarchies.superior_id = 4 OR employees.id = 4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment