Documentation

Visual SQL Query Builder

Visual SQL Query Builder

The Visual SQL Query Builder is a point-and-click surface for assembling SELECT statements without touching a keyboard. Pick columns, add filters from dropdowns, choose join types, and watch the generated SQL update live in the preview panel. When you're happy, hit Run Query to execute against the current table, or copy the SQL and paste it into the SQL Editor for further work.

Quick Start

  1. Open a SQL Table activity on any table.
  2. Click the Query Builder toggle in the toolbar to reveal the builder panel on the right.
  3. Tick the columns you want in the output; add filters, joins, aggregates, and an ORDER BY as needed.
  4. Click Run Query in the panel footer to execute against the table.
  5. Copy the generated SQL to keep iterating in the SQL Editor, or leave the panel open — every run refreshes the table view.

Opening the Builder

The builder is not a standalone activity — it lives as a side panel inside the SQL Table activity, so it always operates against a specific base table. Open the SQL Table activity for the table you want to query, then click the Query Builder toggle in the toolbar. The panel opens on the right and you can resize it by dragging its left edge.

Toggling the panel off keeps its state on the activity — reopen it later and your filters, joins, and aggregates are still there.

Picking Columns Visually

The Columns pane lists every column of the base table, plus columns of any joined tables. Each row exposes:

  • A checkbox — include the column in the SELECT list.
  • A rename field — sets an AS alias.
  • An aggregate dropdown — wrap the column in COUNT, SUM, AVG, MIN, or MAX.
  • A grouping toggle — add the column to GROUP BY.
  • A sort direction — add the column to ORDER BY ASC / DESC.

Adding Filters

Click + Filter to open a filter row. Each filter has three parts:

  1. A column picker (scoped to the tables in the current query).
  2. An operator dropdown.
  3. A value input, type-aware based on the column.
Operator Meaning Value input
=, !=Equality / inequalitySingle value
>, <, >=, <=Numeric / date comparisonsSingle value
BETWEENRange (inclusive)Two values
INValue in a listComma-separated list
LIKEPattern matchPattern with % / _
IS NULL, IS NOT NULLPresence checkNone

Filters are combined with AND by default. Click the AND chip to toggle to OR, or group filters by dragging one onto another.

Foreign-Key Preview & Joins

VisuaLeaf reads foreign-key metadata from the information schema. When you hover a table that is related to a table already in the query, a suggested JOIN condition appears:

Automatic JOIN Suggestions

Example: with orders as the base table, hovering customers shows orders.customer_id = customers.id. Click Add JOIN to accept, or edit the condition manually.

  • Choose INNER, LEFT, RIGHT, or FULL OUTER from the join dropdown.
  • Add multiple join conditions with the + button on the join row.
  • Remove a joined table with the x on its column pane header — all references are cleaned up.

Aggregates & GROUP BY

Wrap any output column with an aggregate function from its dropdown:

  • COUNT, COUNT(DISTINCT)
  • SUM, AVG
  • MIN, MAX

Any non-aggregated column with the Group toggle on is added to the GROUP BY clause automatically. Add a HAVING filter using the + Having button — it works exactly like a filter but applies after aggregation.

ORDER BY and LIMIT

Set sort order per column using the up/down arrows in the columns pane; drag rows in the Sort panel to reorder. The Limit field caps the row count; a checkbox toggles LIMIT on or off entirely.

Live SQL Preview Panel

A collapsible panel at the bottom of the builder shows the generated SQL as you edit. It updates on every change and highlights the fragment corresponding to the pane you last touched, so you can see exactly which clause your click produced.

Getting the SQL Out

Two flows depending on where you want to keep working:

  • Copy to clipboard — the copy icon in the top-right of the Generated SQL preview grabs the query as-is. Paste it into the SQL Editor if you need CTEs, window functions, or anything else the visual builder doesn't expose.
  • Import into the SQL Table's editor — the SQL Table activity has an Import Query Builder SQL action that pushes the current builder output into the activity's own SQL editor pane, in one click.

Walkthrough: Top 20 Customers by Total Order Value

  1. Set base table to orders.
  2. Accept the FK suggestion to join customers on orders.customer_id = customers.id.
  3. Tick customers.name. In its aggregate dropdown, leave it as-is; toggle Group on.
  4. Tick orders.total. Set aggregate to SUM. Rename to total_value.
  5. Add an ORDER BY on total_value descending.
  6. Set LIMIT to 20.
  7. The preview panel shows:
    SELECT customers.name, SUM(orders.total) AS total_value
    FROM orders
    INNER JOIN customers ON orders.customer_id = customers.id
    GROUP BY customers.name
    ORDER BY total_value DESC
    LIMIT 20;
  8. Click Run Query, or copy the generated SQL and paste it into the SQL Editor to keep iterating.

Pro Tips

  1. Model your FKs: The join suggestions rely on declared foreign keys. If your schema lacks them, add relationship hints from the connection settings.
  2. Shape it here, refine it there: The builder is fastest for the initial shape. Once you need CTEs, window functions, or anything else it doesn't expose, copy the generated SQL and finish in the SQL Editor.
  3. Save as a template: Save the built query to the query library and parameterize the filter values for reuse.

Ready to try VisuaLeaf?

Download and start managing your MongoDB databases with ease.

Download Free Trial