New versions: Dev (3.15) | Latest (3.14) | 3.13 | 3.12 | 3.11 | 3.10 | 3.9 | 3.8 | Old versions: 3.7 | 3.6 | 3.5 | 3.4 | 3.3 | 2.6

Comparison predicate

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

In SQL, comparison predicates are formed using common comparison operators:

  • = to test for equality
  • <> or != to test for non-equality
  • > to test for being strictly greater
  • >= to test for being greater or equal
  • < to test for being strictly less
  • <= to test for being less or equal

Unfortunately, Java does not support operator overloading, hence these operators are also implemented as methods in jOOQ, like any other SQL syntax elements. The relevant parts of the org.jooq.Field interface are these:

eq or equal(T);                  // =  (some bind value)
eq or equal(Field<T>);           // =  (some column expression)
eq or equal(Select<T>);          // =  (some scalar SELECT statement)
ne or notEqual(T);               // <> (some bind value)
ne or notEqual(Field<T>);        // <> (some column expression)
ne or notEqual(Select<T>);       // <> (some scalar SELECT statement)
lt or lessThan(T);               // <  (some bind value)
lt or lessThan(Field<T>);        // <  (some column expression)
lt or lessThan(Select<T>);       // <  (some scalar SELECT statement)
le or lessOrEqual(T);            // <= (some bind value)
le or lessOrEqual(Field<T>);     // <= (some column expression)
le or lessOrEqual(Select<T>);    // <= (some scalar SELECT statement)
gt or greaterThan(T);            // >  (some bind value)
gt or greaterThan(Field<T>);     // >  (some column expression)
gt or greaterThan(Select<T>);    // >  (some scalar SELECT statement)
ge or greaterOrEqual(T);         // >= (some bind value)
ge or greaterOrEqual(Field<T>);  // >= (some column expression)
ge or greaterOrEqual(Select<T>); // >= (some scalar SELECT statement)

Note that every operator is represented by two methods. A verbose one (such as equal()) and a two-character one (such as eq()). Both methods are the same. You may choose either one, depending on your taste. The manual will always use the more verbose one.

NULL in jOOQ's comparison predicates

jOOQ has a special way of dealing with null bind values, when you pass them to comparison predicates equal() and notEqual(). For convenience, jOOQ will render IS NULL or IS NOT NULL predicates.

jOOQ's convenience methods using comparison operators

In addition to the above, jOOQ provides a few convenience methods for common operations performed on strings using comparison predicates:

LOWER(TITLE) = LOWER('animal farm')
BOOK.TITLE.equalIgnoreCase("animal farm")


Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo