Answer the question
In order to leave comments, you need to log in
Is it possible to use CASE in LEFT JOIN?
Is it possible to execute a query like this in Postgres:
SELECT
c.controltype AS controltype,
c.coretype AS coretype,
g.name AS group_name,
core.name AS corename,
FROM
controls AS c
LEFT JOIN
groups AS g
ON
g.id = c.group_id
LEFT JOIN
(CASE
WHEN coretype = 'Программа'
THEN programs
WHEN coretype = 'Дисциплина'
THEN disciplines
WHEN coretype = 'Модуль'
THEN modules
END)
AS core
ON
c.core_id = core.id
LEFT JOIN
users AS u
ON
u.id = c.teacher_id
WHERE
id = :id
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question