Есть select
Код: Выделить всё
select * from table1
join table2 on table1.id = table2.fk
and (table2.status = 1 or (table2.status = 0 and table2.id in (select id from PROCEDURE)))
С уважением, Иван.
Код: Выделить всё
select * from table1
join table2 on table1.id = table2.fk
and (table2.status = 1 or (table2.status = 0 and table2.id in (select id from PROCEDURE)))
Код: Выделить всё
select * from
procedure
join table2 on table2.id=procedure.id
join table1 on table1.id = table2.fk
where table2.status = 0
union all
select * from
table2
join table1 on table1.id = table2.fk
where table2.status = 1