fixed join in _buildQuery