14 lines
633 B
SQL
14 lines
633 B
SQL
-- Für gewöhnlich würde man hier gruppieren. Aufgrund des UNIQUE-constraints in "calendar_access_attributed" ist das
|
|
-- jedoch nicht nötig, da dadurch für jeden Eintrag in "calendar" mit gegebener "user_id" höchstens ein Eintrag in
|
|
-- "calendar_access_attributed" passt und da es ein LEFT OUTER JOIN ist, wird es _genau_ ein Eintrag sein
|
|
|
|
SELECT
|
|
x.id AS id,
|
|
x.name AS name,
|
|
x.access_public AS access_public,
|
|
x.access_level_default AS access_level_default,
|
|
y.level AS access_level_attributed
|
|
FROM
|
|
calendars AS x
|
|
LEFT OUTER JOIN calendar_access_attributed AS y ON ((x.id = y.calendar_id) AND (y.user_id = $user_id))
|
|
;
|