Class SelectBuilder
java.lang.Object
io.github.projectunified.craftdatabase.client.sql.helper.SelectBuilder
A builder for
SELECT queries-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the queryAdd columns to select, the default is*static SelectBuilderCreate a new builderdistinct()Add theDISTINCToptionAdd columns to group byAdd a condition to theHAVINGclause, joined to the previous ones withANDAdd a join clause, e.g.limit(int limit) Set the maximum number of rowsAdd an order by expression, e.g.Add a condition, joined to the previous ones withAND
-
Method Details
-
create
Create a new builder- Parameters:
table- the table- Returns:
- the builder
-
distinct
Add theDISTINCToption- Returns:
- this builder for chaining
-
columns
Add columns to select, the default is*- Parameters:
columns- the columns- Returns:
- this builder for chaining
-
join
Add a join clause, e.g.join("LEFT JOIN orders o ON o.user_id = u.id")- Parameters:
join- the join clausevalues- the values for the placeholders, omitted to provide them later in a batch- Returns:
- this builder for chaining
-
where
Add a condition, joined to the previous ones withAND- Parameters:
condition- the condition, the?placeholders must match the valuesvalues- the values for the placeholders, omitted to provide them later in a batch- Returns:
- this builder for chaining
-
groupBy
Add columns to group by- Parameters:
columns- the columns- Returns:
- this builder for chaining
-
having
Add a condition to theHAVINGclause, joined to the previous ones withAND- Parameters:
condition- the condition, the?placeholders must match the valuesvalues- the values for the placeholders, omitted to provide them later in a batch- Returns:
- this builder for chaining
-
orderBy
Add an order by expression, e.g."id DESC"- Parameters:
orderBy- the order by expression- Returns:
- this builder for chaining
-
limit
Set the maximum number of rows- Parameters:
limit- the limit- Returns:
- this builder for chaining
-
build
Build the query- Returns:
- the query
-