Fixed _id ambiguity error in sql statement for inner join and improved
readability