select ter.territoryid as locationId, 'TER' as type, ter.name as location from tbl_ter_territories ter inner join tbl_ter_territorylevels tl on tl.levelid = ter.levelid where ter.ownerid = and ter.fsl_tablecode = and tl.brokerlevel = 1 order by ter.name select broker_office_id as locationid, 'OFC' as type, broker_office_name as location from tblBrokerOffices where broker_id = order by broker_office_name