The jOOQ User Manual : SQL building : SQL Statements : The SELECT statement : SELECT clause | previous : next |
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
SELECT clause
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
The SELECT clause lets you project your own record types, referencing table fields, functions, arithmetic expressions, etc. The Factory provides several methods for expressing a SELECT clause:
-- The SELECT clause SELECT BOOK.ID, BOOK.TITLE SELECT BOOK.ID, TRIM(BOOK.TITLE)
// Provide a varargs Fields list to the SELECT clause: Select<?> s1 = create.select(BOOK.ID, BOOK.TITLE); Select<?> s2 = create.select(BOOK.ID, trim(BOOK.TITLE));
Some commonly used projections can be easily created using convenience methods:
-- Simple SELECTs SELECT COUNT(*) SELECT 0 -- Not a bind variable SELECT 1 -- Not a bind variable
// Select commonly used values Select<?> select1 = create.selectCount(); Select<?> select2 = create.selectZero(); Select<?> select2 = create.selectOne();
See more details about functions and expressions in the manual's section about Column expressions
The SELECT DISTINCT clause
The DISTINCT keyword can be included in the method name, constructing a SELECT clause
SELECT DISTINCT BOOK.TITLE
Select<?> select1 = create.selectDistinct(BOOK.TITLE);
Feedback
Do you have any feedback about this page? We'd love to hear it!