select a.data, b.another_data
from block as a join block_one as b on (a.main_block_id=b.main_block_id)
where a.type = 'one'
union all
select a.data, b.third_data
from block as a join block_two as b on (a.main_block_id=b.main_block_id)
where a.type = 'two'
select distinct a.data,
(case when a.type='one' then b.another_data else c.third_data end) as some_data
from block as a left join block_one as b on (a.type = 'one' and a.main_block_id=b.main_block_id)
left join block_two as c on (a.type = 'two' and a.main_block_id=c.main_block_id)