SELECT ci_agency.*, ci_pageempresa.* FROM `ci_agency` -- JOIN ci_pageempresa ON ci_pageempresa.id_agency = ci_agency.id_agency JOIN ci_pagesconfig ON ci_pagesconfig.id_agency = ci_agency.id_agency WHERE ci_agency.url = 'comparatur' && ci_agency.active = 1