Answer the question
In order to leave comments, you need to log in
How to query related tables in Microsoft SQL Server so that the result is displayed in one column?
3 linked tables SQL 2017, Position - MainTabMatrix, Tasks - TasksM, Functions - Duties.
Должность: Начальник РЭС
Задача: Метрологическое обеспечение РЭС
Функции: 4.4.1 Контролирует ответственного за учет, состояние и применение вспомогательных (переносных) средств измерения в РЭС.
4.4.2 Организует обеспечение единства и требуемой точности измерений в РЭС
4.4.3 Организует ведение базы данных средств измерений в подсистеме, находящихся в эксплуатации структурного подразделения или на обслуживаемом оборудовании.
Select name_site, NameTask, NameDuties
from MainTabMatrix u
JOIN TasksM b ON u.main_id = b.main_id
JOIN Duties p ON b.id_task = p.id_task
WHERE u.name_site = 'Начальник РЭС';
Answer the question
In order to leave comments, you need to log in
SELECT main_id AS [Код], 0 AS [Код.Код], 0 AS [Код.Код.Код], name_site AS [Текст]
FROM MainTabMatrix
WHERE name_site = 'Начальник РЭС'
UNION
SELECT MainTabMatrix.main_id, id_taks, 0, NameTask AS [Текст]
FROM MainTabMatrix
JOIN TasksM ON MainTabMatrix.main_id = TasksM.main_id
WHERE name_site = 'Начальник РЭС'
UNION
SELECT MainTabMatrix.main_id, TasksM.id_taks, duties_id, NameDuties AS [Текст]
FROM MainTabMatrix
JOIN TasksM ON MainTabMatrix.main_id = TasksM.main_id
JOIN Duties ON TasksM.id_task = Duties.id_task
WHERE name_site = 'Начальник РЭС'
ORDER BY 1, 2, 3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question