All versions: 3.11 | 3.10 | 3.9 | 3.8 | 3.7 | Development versions: 3.12 | Unsupported versions: 3.6 | 3.5 | 3.4 | 3.3 | 3.2 | 2.6
Column expressions can be used in various SQL clauses in order to refer to one or several columns. This chapter explains how to form various types of column expressions with jOOQ. A particular type of column expression is given in the section about tuples or row value expressions, where an expression may have a degree of more than one.
Using column expressions in jOOQ
jOOQ allows you to freely create arbitrary column expressions using a fluent expression construction API. Many expressions can be formed as functions from DSL methods, other expressions can be formed based on a pre-existing column expression. For example:
// A regular table column expression Field<String> field1 = BOOK.TITLE; // A function created from the DSL using "prefix" notation Field<String> field2 = trim(BOOK.TITLE); // The same function created from a pre-existing Field using "postfix" notation Field<String> field3 = BOOK.TITLE.trim(); // More complex function with advanced DSL syntax Field<String> field4 = listAgg(BOOK.TITLE) .withinGroupOrderBy(BOOK.ID.asc()) .over().partitionBy(AUTHOR.ID);
In general, it is up to you whether you want to use the "prefix" notation or the "postfix" notation to create new column expressions based on existing ones. The "SQL way" would be to use the "prefix notation", with functions created from the DSL. The "Java way" or "object-oriented way" would be to use the "postfix" notation with functions created from org.jooq.Field objects. Both ways ultimately create the same query part, though.
Table of contents
- 4.6.1.
- Table columns
- 4.6.2.
- Aliased columns
- 4.6.3.
- Cast expressions
- 4.6.4.
- Datatype coercions
- 4.6.5.
- Arithmetic expressions
- 4.6.6.
- String concatenation
- 4.6.7.
- General functions
- 4.6.8.
- Numeric functions
- 4.6.9.
- Bitwise functions
- 4.6.10.
- String functions
- 4.6.11.
- Case sensitivity with strings
- 4.6.12.
- Date and time functions
- 4.6.13.
- System functions
- 4.6.14.
- Aggregate functions
- 4.6.15.
- Window functions
- 4.6.16.
- Grouping functions
- 4.6.17.
- User-defined functions
- 4.6.18.
- User-defined aggregate functions
- 4.6.19.
- The CASE expression
- 4.6.20.
- Sequences and serials
- 4.6.21.
- Tuples or row value expressions
The jOOQ User Manual. Multiple Pages : SQL building : Column expressions | previous : next |