Fixed multiple rows bug

Make sure to have ON x.z=y.z condition for joins.