Generic solution for selects

Keep the special cases (and add a new one), as they generate smaller constraints.