added inner joins to sql