# SQL Builder Tools

The **SQL Builder** provides a comprehensive set of tools that allow users to visually construct SQL queries based on existing **ER Diagrams**, without writing SQL syntax manually.\
These tools support selecting tables, defining joins, configuring query logic, and previewing generated SQL and result data.

***

### Using ER Diagrams to Build Queries

Users can expand the **My ER Diagram** section in the left‑hand Side Menu to view all ER Diagrams available in the application.

To start building a query:

1. Select an ER Diagram
2. Drag and drop a table from the Side Menu onto the **design panel**

Once a table is dropped onto the design panel, all columns of that table are displayed and available for query configuration.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FaQxvaYCabUHIq0GP6A5A%2Fimage.png?alt=media&#x26;token=3aa8982e-ba6b-4e2e-818d-caf4eab72c3b" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FBqWlwS44kgT8nWaR6pyt%2Fimage.png?alt=media&#x26;token=56109468-a72d-4790-9115-de4ddafb8ef4" alt=""><figcaption></figcaption></figure>

***

### Reusing Existing SQL Builder Queries

Under the **My Query** section in the Side Menu, users can see all existing SQL Builder projects within the same application.

* Queries can be dragged and dropped into the design panel
* The dropped query acts as a **subquery**
* Its output is represented as a virtual table

This enables construction of more complex, layered SQL queries.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2F9fmlfUNZD0szqAl5AKiP%2Fimage.png?alt=media&#x26;token=c5efe0b0-d3fd-462b-872b-16963b1d9c66" alt=""><figcaption></figcaption></figure>

***

### SQL Builder Configuration Panel

The **Configuration Panel** displays the current SQL configuration being built.\
It provides multiple tabs, each representing a different aspect of the query.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FyKQt2m5L6M9UKf8KKvad%2Fimage.png?alt=media&#x26;token=88847a53-c1b0-4405-9d84-167cd8a1c023" alt=""><figcaption></figcaption></figure>

#### Configuration Tabs

* **Columns**\
  Displays the selected columns included in the query.
* **Union List**\
  Used to configure `UNION` operations with other SQL Builder queries.
* **Join List**\
  Displays and manages join conditions between tables.
* **Query**\
  Shows the generated SQL statement based on the visual configuration.
* **Data**\
  Executes the SQL against a valid connection and displays sample results\
  \&#xNAN;*(Current version retrieves the first 5 records)*

***

### Columns Tab – Column Configuration

Columns selected on the design panel are listed in the **Columns** tab, where users can apply additional configurations.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FoBL85iDLZdwlKZKEgIBf%2Fimage.png?alt=media&#x26;token=742ee091-9f23-4916-a3ea-24d8c04afd2b" alt=""><figcaption></figcaption></figure>

#### Column Features

* **Select**\
  Include or exclude columns from the `SELECT` clause\
  Columns can be removed using the delete (`x`) icon.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2Fng3OxkgFK7tm9LJIPjVf%2Fimage.png?alt=media&#x26;token=ea866a82-7ace-416f-bbec-fd688aee087f" alt=""><figcaption></figcaption></figure>

* **Function**\
  Apply SQL aggregation or transformation functions such as `MIN`, `MAX`, `COUNT`.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FrbGjBx4BibmmIVohGpRY%2Fimage.png?alt=media&#x26;token=7a5bd20d-248a-4762-8b21-459840358e68" alt=""><figcaption></figcaption></figure>

* **Distinct**\
  Mark the column as `DISTINCT` in the select clause.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FEZtdbkCkgbcxIBUuogNk%2Fimage.png?alt=media&#x26;token=2c0860fa-c50a-45bb-9b8a-f485064b6eb1" alt=""><figcaption></figcaption></figure>

* **Alias**\
  Define an alias name for the selected column.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2F0pvNpVdkPfGMKb9OHzhn%2Fimage.png?alt=media&#x26;token=f4ffde6c-2552-4a03-8b53-07895f96bea2" alt=""><figcaption></figcaption></figure>

Additional options include:

* **Object** (schema and table name)
* **Group By**
* **Having**
* **Sort** and **Sort Type** (ASC / DESC)

***

### Union List Tab

The **Union List** tab allows users to combine multiple SQL Builder queries using `UNION`.

* Only queries dragged into the design panel are available
* Supports building complex result sets from multiple sources

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2Fo7dRyAyeZ5XIfhsBNNfo%2Fimage.png?alt=media&#x26;token=a5f9c41e-a1ec-4ef3-860f-3c92ce8a99d1" alt=""><figcaption></figcaption></figure>

***

### Join List Tab

The **Join List** tab is used to configure join relationships between tables in the query, based on relationships defined in the ER Diagram.

***

### Query Tab

The **Query** tab displays the final SQL statement generated from all visual configurations.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2F9bPDaAWHqzmjOb0U39Yy%2Fimage.png?alt=media&#x26;token=b1aaca7a-9d6e-4d11-bd16-32a5b5b3a5ec" alt=""><figcaption></figcaption></figure>

***

### Data Tab – Execute Query

The **Data** tab allows users to execute the generated SQL against a configured database connection and preview the output.

* Displays sample query results
* Currently limited to the first **5 records**

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FeDDRUREadv7Rf8R6FDUt%2Fimage.png?alt=media&#x26;token=93b7ebb8-c22d-48e3-be3a-e585b3dc24ad" alt=""><figcaption></figcaption></figure>

***

### Additional SQL Builder Actions

#### New Concatenated Column

Create a new derived column by concatenating multiple fields.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FqmdOZJVj9TRIr3Iw3iW9%2Fimage.png?alt=media&#x26;token=e87f359d-9168-4b85-ba89-7f2b1c444f9b" alt=""><figcaption></figcaption></figure>

***

#### Condition Wizard

The **Condition Wizard** helps users define `WHERE` and `GROUP BY` conditions without writing SQL.

Users can:

* Add multiple conditions
* Combine conditions logically

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FXr6kZtQGNBZt1S8DWil3%2Fimage.png?alt=media&#x26;token=c642d270-fbdb-49c4-a5b3-459ad0d183a1" alt=""><figcaption></figcaption></figure>

***

#### Save and Exit

* **Save** – Persist the SQL Builder configuration
* **Exit** – Close the current SQL Builder project

***

### Summary

The **SQL Builder Tools** provide a powerful, visual environment for building SQL queries in a low‑code manner.

With SQL Builder, users can:

* Design queries directly from ER Diagrams
* Reuse queries as subqueries
* Configure joins, unions, and conditions visually
* Preview generated SQL and result data
* Build complex queries without SQL syntax knowledge

These tools make SQL Builder a key component of ONEWEB’s **Database Tools**, enabling efficient and governed data access in low‑code applications.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onewebstack.com/designer-reference/data-designer/sql-builder/sql-builder-tools.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
