Selecting a set of basis states is a common task in quantum computing, in order to increase and/or evaluate their probabilities. This is similar to designing WHERE clauses in classical database queries. Even though one can find heuristic methods to achieve this, it is desirable to automate the process. A common, but inefficient automation approach is to use oracles with classical evaluation of all the states at circuit design time. In this paper, we present a novel, canonical way to produce a quantum oracle from an algebraic expression (in particular, an Ising model), that maps a set of selected states to the same value, coupled with a simple oracle that matches that particular value. We also introduce a general form of the Grover iterate that standardizes this type of oracle. We then apply this new methodology to particular cases of Ising Hamiltonians that model the zero-sum subset problem and the computation of Fibonacci numbers. In addition, this paper presents experimental results obtained on real quantum hardware, the new Honeywell computer based on trapped-ion technology with quantum volume 64.