SELECT Requests.r_id, Requests.u_id, Requests.c_id, Requests.sent, Requests.type, Requests.rdate, ROpt_City.container as city, ROpt_date.container as actionDate
FROM Requests
LEFT JOIN ROlink ON (ROlink.r_id = Requests.r_id)
JOIN ROptions AS ROpt_City ON (ROlink.op_id = ROpt_City.op_id AND ROpt_City.name = 'adres')
LEFT JOIN ROlink as ROlink2 ON (ROlink2.r_id = Requests.r_id)
JOIN ROptions AS ROpt_date ON (ROlink2.op_id = ROpt_date.op_id AND ROpt_date.name = 'data-vypolneniya')
SELECT Requests.r_id, ROpt_City.container, ROpt_Filial.container, UOptions.container
FROM Requests
LEFT JOIN ROlink ON (ROlink.r_id = Requests.r_id)
LEFT JOIN ROptions AS ROpt_City ON (ROlink.op_id = ROpt_City.op_id AND ROpt_City.name = 'adres')
LEFT JOIN ROptions AS ROpt_Filial ON (ROlink.op_id = ROpt_Filial.op_id AND ROpt_City.name = 'data-vypolneniya')
LEFT JOIN UOlink ON (ROpt_City.op_id = UOlink.op_id OR ROpt_Filial.op_id = UOlink.op_id)
LEFT JOIN UOptions ON (UOlink.op_id = UOptions.op_id AND UOptions.name = 'fio')
Написано
Войдите на сайт
Чтобы задать вопрос и получить на него квалифицированный ответ.
SELECT Requests.r_id, Requests.u_id, Requests.c_id, Requests.sent, Requests.type, Requests.rdate, ROpt_City.container as city, ROpt_date.container as actionDate
FROM Requests
LEFT JOIN ROlink ON (ROlink.r_id = Requests.r_id)
JOIN ROptions AS ROpt_City ON (ROlink.op_id = ROpt_City.op_id AND ROpt_City.name = 'adres')
LEFT JOIN ROlink as ROlink2 ON (ROlink2.r_id = Requests.r_id)
JOIN ROptions AS ROpt_date ON (ROlink2.op_id = ROpt_date.op_id AND ROpt_date.name = 'data-vypolneniya')