Added optional condition to selectJoin()