select s.section, sectionid from fslibrary.dbo.tbl_cmm_sections s inner join tbl_cus_customers c on (s.ownerid = c.fsl_companyid and s.fsl_tablecode = c.fsl_tablecode) inner join tbl_cus_websites w on (c.customerid = w.customerid) where w.websiteid = order by section;