Documentation

Visual SQL Query Builder

Visual SQL Query Builder

The Visual SQL Query Builder is a point-and-click canvas for assembling SELECT statements. Each table in the query is a card on the canvas, joins are drawn as lines between them, and filters and sorting live in a panel on the right. The generated SQL updates live underneath as you work. When you're happy, hit Run Query to see the results in the same tab, or switch to SQL and keep editing by hand.

Quick Start

  1. Open a table (right-click it in the connection tree and choose Open Table Query).
  2. Click Query Builder in the toolbar. The builder opens with that table on the canvas, marked Current.
  3. Click Join table to bring in related tables, and + Add field on a card to choose output columns.
  4. Add conditions under Where and sorts under Order By.
  5. Click Run Query (F5). The results open in the Results tab under the canvas.
Query Builder on the Verdant Market orders table: orders and customers cards joined by a LEFT JOIN line on customer_id, Where and Order By panels on the right, and the generated SQL with a 50-row Results grid below

Opening the Builder

The builder belongs to a table's query tab, so it always starts from a specific table. Open the table, then click Query Builder in the toolbar (next to SQL). The builder fills the tab: the canvas on the left, the Where and Order By panels on the right, and the Generated SQL and Results tabs along the bottom. The header shows how many tables are in the query, with buttons to shrink the builder back down or close it.

Switching back to SQL keeps the builder's state — return to it later and your tables, joins, and conditions are still there. Edit as SQL copies the generated query into the SQL editor so you can carry on by hand.

Moving Around the Canvas

Drag a card to move it, drag the empty canvas to pan, and scroll to zoom. The controls in the bottom-left corner zoom in and out, show the current zoom level, fit every card on screen, and tidy the cards into a clean layout.

Close-up of the join canvas: the orders card marked Current, the customers card with its LEFT JOIN orders ON customer_id = customer_id row, a line linking the two customer_id fields, and zoom controls at 100%

Picking Columns

Until you pick any columns, the query returns every column of the current table. To choose the output yourself, use the buttons on each table card:

  • + Add field — search the table's columns and add them to the SELECT one after another.
  • Show every column (the columns icon) — lists all of the table's columns with checkboxes, so you can tick and untick them directly on the card.
  • Add all fields (the stacked-layers icon) — adds every column of that table at once.
  • alias — the box next to the table name sets the alias used for the table in the generated SQL.

Join columns are marked with a key icon, and the remove button next to a field takes it back out of the SELECT.

Adding Filters

The Where panel holds your conditions. Each condition row has three parts:

  1. A column picker (scoped to the tables on the canvas).
  2. An operator picker, offering the operators that suit the column's type.
  3. A value input.
Operator Meaning Value input
=, !=Equality / inequalitySingle value
>, <, >=, <=Numeric / date comparisonsSingle value
BETWEENRange (inclusive)From and to values
IN, NOT INValue in a listComma-separated list
LIKE, NOT LIKE, ILIKEPattern match (ILIKE ignores case)Pattern with % / _
IS NULL, IS NOT NULLPresence checkNone

Conditions in a group are combined with And; switch the group's dropdown to Or to change that. + Group adds a nested group with its own And/Or, + Expression adds another condition, and you can drag conditions to reorder them. The check mark at the start of a row turns a condition off without deleting it.

Joining Tables

Click Join table in the top-left corner of the canvas to add another table. VisuaLeaf reads the foreign keys in your schema, so the list puts related tables first and tells you how each one would connect.

Automatic JOIN Suggestions

Example: with orders as the current table, the list offers customers via customers.customer_id = orders.customer_id and addresses via addresses.address_id = orders.shipping_address_id. Pick one and the card arrives already joined on that condition. Tables with no foreign key to the query are listed after the related ones.

Join table search list for orders, showing related tables such as addresses, customers, employees, order_items and payments with the foreign key each would join on

Each joined card carries its join settings at the top:

  • Choose INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN, or CROSS JOIN, and which table it joins to.
  • Change the ON columns on either side of the =. The line on the canvas follows the columns you pick.
  • Remove the relationship with the delete button on the join row, or remove the whole table with the delete button on the card header.

Aggregates & GROUP BY

Hover the + next to a field on a card to wrap it in an aggregate:

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

As soon as one field is aggregated, every other field is marked GROUP and goes into the GROUP BY clause for you. A Having panel also appears on the right for filtering on aggregated values. Click an aggregate badge to remove it.

ORDER BY and Paging

Click + Add Sort in the Order By panel, pick a column, and choose ascending or descending. Add more sorts for tie-breakers; the counter next to the heading shows how many are set. How many rows come back per page is set in the results grid, the same way as for any other query.

Live SQL Preview Panel

The Generated SQL tab under the canvas shows the query as you build it, and updates on every change. While the Results tab is open, the generated SQL stays visible on a single line beside the tabs, so you can always check what will run.

Getting the SQL Out

Two ways to take the query further:

  • Copy SQL — the copy button on the Generated SQL tab 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 cover.
  • Edit as SQL — the toolbar button puts the generated query into the tab's own SQL editor in one click.

Reset clears the builder back to just the current table.

Walkthrough: Top Customers by Total Order Value

  1. Open the orders table and click Query Builder.
  2. Click Join table and pick customers (via customers.customer_id = orders.customer_id). Set the join type to INNER JOIN.
  3. On the customers card, click + Add field and add email.
  4. On the orders card, add total and set its aggregate to SUM. email is now marked GROUP.
  5. Under Order By, click + Add Sort and sort by the summed total, descending.
  6. The Generated SQL tab shows something like:
    SELECT "customers"."email", SUM("orders"."total")
    FROM "market"."orders"
    INNER JOIN "market"."customers" ON "orders"."customer_id" = "customers"."customer_id"
    GROUP BY "customers"."email"
    ORDER BY SUM("orders"."total") DESC
  7. Click Run Query (F5), or Edit as SQL to keep refining by hand.

Pro Tips

  1. Model your FKs: The join suggestions come from declared foreign keys. Without them, Join table still lists every table, but you set the ON columns yourself.
  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 cover, use Edit as SQL and finish by hand.
  3. Tidy the canvas: With several joined tables, use the layout button in the zoom controls to rearrange the cards, then fit them on screen.

Ready to try VisuaLeaf?

Download and start managing your MongoDB and SQL databases with ease.

Download Free Trial