CRM-12715 backport multiple fields query fix on JOIN