Available in versions: Dev (3.21) | Latest (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11

Conditional expressions

Supported by ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

Conditions or conditional expressions are widely used in SQL and in the jOOQ API. They can be used in

Boolean types in SQL

Before SQL:1999, boolean types did not really exist in SQL. They were modelled by 0 and 1 numeric/char values. With SQL:1999, true booleans were introduced and are now supported by most databases. In short, these are possible boolean values:

  • 1 or TRUE
  • 0 or FALSE
  • NULL or UNKNOWN

It is important to know that SQL differs from many other languages in the way it interprets the NULL boolean value. Most importantly, the following facts are to be remembered:

  • [ANY] = NULL yields NULL (not FALSE)
  • [ANY] != NULL yields NULL (not TRUE)
  • NULL = NULL yields NULL (not TRUE)
  • NULL != NULL yields NULL (not FALSE)

For simplified NULL handling, please refer to the section about the DISTINCT predicate.

Note that jOOQ does not model these values as actual column expression compatible.

Table of contents

3.12.1.
Condition building
3.12.2.
TRUE and FALSE condition
3.12.3.
BOOLEAN columns
3.12.4.
AND, OR, NOT boolean operators
3.12.5.
Boolean operator precedence
3.12.6.
XOR boolean operator
3.12.7.
Comparison predicate
3.12.8.
Comparison predicate (degree > 1)
3.12.9.
Quantified comparison predicate
3.12.10.
BETWEEN predicate
3.12.11.
BETWEEN predicate (degree > 1)
3.12.12.
DISTINCT predicate
3.12.13.
DISTINCT predicate (degree > 1)
3.12.14.
DOCUMENT predicate
3.12.15.
EXISTS predicate
3.12.16.
IN predicate
3.12.17.
IN predicate (degree > 1)
3.12.18.
JSON predicate
3.12.19.
JSON_EXISTS predicate
3.12.20.
LIKE predicate
3.12.21.
LIKE predicate (binary) (new)
3.12.22.
LIKE REGEX predicate
3.12.23.
Quantified LIKE predicate
3.12.24.
Quantified LIKE predicate (binary) (new)
3.12.25.
STARTS_WITH predicate
3.12.26.
ENDS_WITH predicate
3.12.27.
CONTAINS predicate
3.12.28.
NULL predicate
3.12.29.
NULL predicate (degree > 1)
3.12.30.
OVERLAPS predicate
3.12.31.
SIMILAR TO predicate
3.12.32.
Spatial predicates
3.12.32.1.
ST_Contains
3.12.32.2.
ST_Crosses
3.12.32.3.
ST_Disjoint
3.12.32.4.
ST_Equals
3.12.32.5.
ST_Intersects
3.12.32.6.
ST_IsClosed
3.12.32.7.
ST_IsEmpty
3.12.32.8.
ST_IsRing (new)
3.12.32.9.
ST_IsSimple (new)
3.12.32.10.
ST_IsValid (new)
3.12.32.11.
ST_Overlaps
3.12.32.12.
ST_Touches
3.12.32.13.
ST_Within
3.12.33.
UNIQUE predicate
3.12.34.
XMLEXISTS predicate
3.12.35.
Query By Example (QBE)

previous : next

Feedback

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

The jOOQ Logo