SELECT ci_agency.*, ci_home.* FROM `ci_agency` -- JOIN ci_home ON ci_home.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