Restricting a query with predicates on fields

In most cases, you do not need to process all rows in a table. Typically, you need to restrict the set of rows, for example, by date or geographic location.

A predicate is a condition that selects a subset of values from a larger set. Predicates are independent of the sets to which you apply them. You can create predicates to apply to multiple sets of values to select subsets of those values. For example, the expression “is male” is a predicate that comprises a comparison operator, “is,” and a comparison value, “male.” You can apply this predicate to different sets of people. If you apply the predicate “is male” to the set of people in your family, the predicate selects all the male members of your family. If you apply the predicate to the set of people in your work group, “is male” selects a different, possibly overlapping subset of male people.

SQL SELECT statements provide WHERE and HAVING clauses to apply predicates to the sets of values in specific database columns. The query builder APIs provide methods on query objects to apply predicates to the sets of values in specific entity fields.

See also