Skip to content

Instantly share code, notes, and snippets.

@hermansc
Created October 17, 2011 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hermansc/1293837 to your computer and use it in GitHub Desktop.
Save hermansc/1293837 to your computer and use it in GitHub Desktop.
SELECT sc.id, sc.title, sh.id, shift.begin, shift.end, shift.unwanted as w, u.username
FROM shiftmanager_schedule sc
JOIN shiftmanager_schedule_shifts sh ON (sc.id = sh.schedule_id)
JOIN shiftmanager_shift shift ON (shift.id = sh.id)
JOIN auth_user u ON (shift.owner_id = u.id)
WHERE sc.owned_by_id IN(
SELECT sch.owned_by_id
FROM aktive_verv av
JOIN shiftmanager_schedule sch ON (sch.owned_by_id = av.gruppe_id)
WHERE av.medlem_id = 1012912) OR sc.owned_by_id IN (SELECT sc.owned_by_id FROM shiftmanager_shift shift
JOIN shiftmanager_schedule_shifts sh ON (shift.id = sh.shift_id)
JOIN shiftmanager_schedule sc ON (sc.id = sh.schedule_id)
JOIN auth_user au ON (shift.owner_id = au.id)
WHERE au.id = 1012912);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment