Help home > SQL Builder
SQL Builder
Build SQL by placing tables, checking columns and connecting columns to join them. Besides SELECT, you can build INSERT, UPDATE, DELETE and CREATE VIEW statements.
What you can do
| Task | How to open |
|---|---|
| Open an empty SQL Builder | š§© SQL Builder in the top bar, "Tools" ā "SQL Builder" in the menu, or right-click a connection name in the tree and choose "SQL Builder" |
| Open with a table already added | Right-click a table or view in the tree and choose "Open in SQL Builder" |
Getting started: building a SELECT (4 steps)
Place tables
Drag and drop tables from the tree, or pick them with + Add Table. Tables linked by foreign keys are joined automatically (see Tables and joins).Choose columns
Check columns in a table to list them in the grid below and include them in the SELECT.Add conditions and sorting
Type something like= 1in the "Condition" column of the grid to add a WHERE clause (see Column grid).Run
The finished SQL appears at the bottom right. ā¶ Run runs it in a SQL tab.
Tables and joins
| Task | How |
|---|---|
| Move a table | Drag its header |
| Join | Drag a column and drop it on a column of another table (a line connects them). Tables with foreign keys between them are joined automatically when added |
| Change or remove a join | Click the line and choose "Inner Join", "Left Outer Join", "Right Outer Join", "Full Outer Join" or "Delete Join". Joins other than inner joins are drawn as dashed lines |
| Change the alias | Double-click the header, or right-click it and choose "Change Alias...". Aliases are assigned A, B, C⦠in the order tables are added |
| Select or clear all columns | Right-click the header and choose "Select All Columns" or "Clear Selection" |
| Make a table first | Right-click the header and choose "Move to First (First in FROM / Update Target)". The first table's header has a different color |
| Remove | Ć in the header |
CROSS JOIN (every combination). That can produce a huge number of rows, so check that you haven't forgotten a join.Column grid (show, alias, aggregate, sort, condition)
| Column | Contents |
|---|---|
| ā ā | Changes the order of columns in the SELECT |
| Show | Whether the column appears in the SELECT. Uncheck it to use the column only for conditions or sorting |
| Alias | The AS name. When empty, the column name is used |
| Aggregate | COUNT, SUM, AVG, MIN, MAX, COUNT DISTINCT. When any column is aggregated, the other shown columns go into GROUP BY |
| Sort, Order | Ascending or descending. With several sort columns, they are applied in ascending "Order" (grid order when empty) |
| Condition | Start with an operator (=, <>, >=, LIKE, IN, IS, BETWEEN and so on) to make it a condition on that column. Anything else goes into the WHERE clause as is. Multiple conditions are combined with AND. Conditions on aggregated columns go into HAVING |
Condition examples: = 1, LIKE 'Sm%', IN (1, 2, 3), IS NULL, BETWEEN '2024-01-01' AND '2024-12-31'
DISTINCT in the toolbar removes duplicates, and Max limits the number of rows (TOP in SQL Server, FETCH FIRST in Oracle, LIMIT elsewhere).
SQL types
| Type | SQL built |
|---|---|
| SELECT | A SELECT with the chosen columns, joins, conditions, aggregates and sorting |
| CREATE VIEW | A statement that turns the SELECT into a view named "View name" |
| INSERT | Inserts one row into the first table, using the "Target" columns and their "Value" |
| UPDATE | Sets the "Target" columns of the first table to "Value". "Condition" becomes the WHERE clause |
| DELETE | Deletes the rows of the first table that match "Condition" |
Write each "Value" as an SQL expression. Quote text with ', as in 'Smith'. An empty value means NULL.
Opening in a SQL tab and running
The finished SQL appears at the bottom right. Open in SQL Tab puts it in a new SQL tab, and ā¶ Run (SELECT only) opens it and runs it right away. From the second time on, ā¶ Run replaces the SQL in the previous result tab and runs it (if you closed that tab or edited its SQL by hand, it runs in a new tab). For INSERT, UPDATE and DELETE, review the statement in the SQL tab before running it.
The SQL Builder's contents are not saved to a file. To keep the SQL, save it from the SQL tab.
FAQ
"+ Add Table" is disabled
No connection is selected, or it isn't connected. Select a connection in the list at the top left and connect to it in the tree.
The "+ Add Table" list is empty
In SQL Server and similar databases, if the connection settings don't specify a database, you are connected to the login's default database (such as master), which has no user tables. Choose the database in the database list to the right of the connection (choosing "connection name / database name" does the same).
I can't draw a join line
Grab a column row and release it over a column row in another table. You can't join columns within the same table (add the same table twice for a self-join).
Tables disappeared when I changed the connection
The other connection may not have those tables, so changing the connection removes the tables you placed.
ā² Back to top