select * from (
    select 2 as etype, bs.blat_id, null as BLAT_MODE, bs.blat_display_name, bp.bp_enabled as enabled, bp.proj_id, p.proj_name as proj_name, null as rtag_id, '' as rtag_name, null as official from blat_servers bs, blat_projects bp, projects p where bs.blat_id = bp.blat_id and p.proj_id = bp.proj_id
    UNION
    select 3 as etype, bs.blat_id, null, bs.blat_display_name, br.br_enabled as enabled, rt.proj_id, p.proj_name as proj_name, rt.rtag_id, rt.rtag_name, rt.official as official from blat_servers bs, blat_releases br, release_tags rt, projects p where br.rtag_id = rt.rtag_id and rt.proj_id = p.proj_id AND bs.blat_id = br.blat_id
    UNION
    select 0 as etype, bs.blat_id, bs.BLAT_MODE, bs.blat_display_name, bs.blat_enable as enabled, null as proj_id, '' as proj_name, null as rtag_id, '' as rtag_name, null as official from blat_servers bs
)
order by blat_id, etype, UPPER(proj_name), UPPER(rtag_name)


