select * from (select 0 o from table) t left join table on table.id=@id left join table2 on table2.id=@id2