Tools mentioned in this article
Open the browser-based tool while you read and try the workflow immediately.
What is a SQL builder?
A SQL builder lets you assemble a SELECT statement visually: you enter table names, the columns you want, filter conditions, and JOIN conditions, and the SQL is generated for you.
Instead of recalling syntax from scratch every time, you organize the conditions in a form — which suits both SQL beginners who are still learning and day-to-day data extraction work.

It is particularly handy when you want to:
- Double-check basic
SELECT,WHERE, andORDER BYsyntax - Build queries that use
INNER JOINandLEFT JOIN - Work out join conditions between tables while writing the SQL
- Produce a draft query as a starting point for review or investigation
- Draft SQL entirely in your browser
The DevToolKits Visual SQL Builder runs in the browser.
Table names and conditions are never sent to a server — the SQL is generated locally.
Building a query step by step
Start by breaking down what you want: which table, under which conditions, in what order.
Doing this decomposition before writing any SQL reduces mistakes.
- Pick the main table.
- Add the columns you want to retrieve.
- Specify
WHEREconditions as needed. - Add a
JOINif another table is required. - For aggregation, choose an aggregate function (
COUNT/SUM/AVG/MIN/MAX),GROUP BYandHAVING. - Set ordering (
ORDER BY),LIMIT/OFFSETandDISTINCTas needed. - Review the generated SQL, and tidy it with the SQL Formatter if needed.
For example, to check the number of orders per user, join the users and orders tables:
SELECT
users.id,
users.name,
COUNT(orders.id) AS order_count
FROM users
LEFT JOIN orders ON users.id = orders.user_id
WHERE users.deleted_at IS NULL
GROUP BY users.id, users.name
ORDER BY order_count DESC;
Queries like this are easy to get wrong when you are new to SQL — a forgotten join condition or GROUP BY column is typical.
Organizing each part in the builder keeps “which tables am I joining?” and “what am I filtering on?” visible at all times.
Aggregation, sorting and subqueries
Aggregate queries like the example above can be built from the form alone.
- Aggregate columns: choose from
COUNT/SUM/AVG/MIN/MAX. If you leave the alias (AS) empty, a name such ascount_allorsum_priceis added automatically. - GROUP BY: when there are aggregate columns, any selected column that isn’t aggregated is added to
GROUP BYautomatically (forgetting it is an error in most databases). - HAVING: filter on the aggregated results.
- ORDER BY: sort ascending or descending by a column or by an aggregate column’s alias.
- LIMIT / OFFSET: only integers of 0 or more are output.
OFFSETis only output when there is aLIMIT(anOFFSETon its own is an error in SQLite and MySQL). - DISTINCT: removes duplicate rows.
- Subqueries (right side of
WHERE): withIN/NOT INor comparisons such as=and>, you can place a one-level(SELECT … FROM … WHERE …)on the right-hand side. Choosing an aggregate function gives a scalar comparison such as(SELECT AVG(price) FROM …). - AND / OR and BETWEEN: from the second row on, each
WHEREcondition can be joined withANDorOR.ANDbinds tighter thanOR, so when there is anOR, conditions joined byANDare wrapped in parentheses in the output (for example(a = 1 AND b = 2) OR c = 3).BETWEENtakes a lower and an upper bound. - EXISTS / NOT EXISTS: choosing it as the operator gives a correlated subquery that checks whether a row matches a column of the outer table (
EXISTS (SELECT 1 FROM orders WHERE orders.user_id = users.id)). When it uses the same table as the outer query, the inner one gets an alias (users_2). - UNION / UNION ALL and WITH (CTEs): the tabs at the top let you add queries to join and CTEs. Each tab has its own tables, conditions and aggregation, and the
ORDER BY,LIMITandOFFSETset on the main query apply to the whole UNION (the ORDER BY is output with column names only, because it sorts the combined result). - Subqueries in FROM: a query made with “Add FROM subquery” is expanded as
FROM (SELECT …) AS namewhen you use its name as the table name in the main query (or a JOIN). It isn’t written toWITH. - Window functions: choose
ROW_NUMBER,RANK,DENSE_RANK,SUM,AVG,COUNT,MIN,MAX,LAGorLEAD, and enterPARTITION BYandORDER BY(a direction can be given too, as inusers.salary DESC). Ranking functions,LAGandLEADaren’t output without anORDER BY.
Beyond SELECT, you can build INSERT / UPDATE / DELETE in the section below. Stored procedures and syntax that differs a lot between databases, such as MERGE, are not supported.
How value quoting is decided automatically
WHERE values are entered as plain text, but pasting them into SQL unmodified would turn a numeric condition like age > 20 into age > '20' with an unwanted quote. The builder inspects each value: a number is left bare, and anything else is wrapped in single quotes automatically. The rules are:
| Input | Output | Why |
|---|---|---|
20 / -1.5 / 1e3 |
unchanged | can be written as a decimal number |
007 / 0x1F |
'007' / '0x1F' |
a number with a leading 0 is kept as a string so the 0 in zip codes and codes isn’t lost; hexadecimal is treated as a string in MySQL |
active |
'active' |
not a number, so it is quoted automatically |
'active' |
'active' |
a value you already quoted yourself is respected as-is |
O'Reilly |
'O''Reilly' |
a single quote inside a value is escaped by doubling it to '' |
The operator matters too. A LIKE / NOT LIKE pattern is always a string, even if it looks like a number. IN / NOT IN checks each comma-separated value one by one and builds a list such as (1, 2, 'a'). IS NULL / IS NOT NULL take no value.
How to think about JOINs
When unsure which JOIN to use, first decide which rows you want to keep.
INNER JOIN returns only rows that match in both tables — right for “only users who have orders”.
LEFT JOIN keeps every row of the left table and attaches the right table where it matches — right for “all users, including those with no orders”.
The common cases:
| What you want | JOIN type |
|---|---|
| Only users that have orders | INNER JOIN |
| All users, including those without orders | LEFT JOIN |
| Attach lookup/master data | LEFT JOIN |
| Restrict to rows with related data | INNER JOIN |
With the builder you can flip the JOIN type and watch the generated SQL change — which also makes it a good learning aid for comparing behavior. For the full picture — RIGHT JOIN, FULL JOIN, self joins, and the classic “LEFT JOIN turns into an INNER JOIN” pitfall — see SQL JOIN Types: Complete Reference.
Joining more than two tables
Adding more tables just means adding more JOINs in the builder. The join order is rearranged so that it follows from tables already connected to FROM, so you don’t have to worry about the order you entered them in.
- Using the same table twice (self-join): the second and later copies get an alias such as
<table name>_2to tell them apart. - A table with no join condition: it isn’t silently dropped; it stays as a
CROSS JOIN, which is what that setup literally means (a Cartesian product). - Loading from DDL: paste
CREATE TABLEstatements and the join conditions are built from the foreign keys. When there are two foreign keys between the same two tables, the second is added withANDinstead of as a new JOIN.
Each join you add appends one more line, so it stays easy to trace — both in the form and in the generated SQL — which tables are connected to which.
Checklist before running generated SQL
Before executing a generated query, confirm:
- Table and column names match the actual database
- No join condition is missing
WHEREconditions are neither too strict nor too loose- For aggregations, the
GROUP BYgranularity is correct ORDER BY/LIMITare present where needed- The query won’t be too heavy against production data
A SQL builder produces a draft. The final check should include your database’s dialect, indexes, and execution plan.
Why it works well for learning SQL
SQL is learned faster by understanding what each clause is responsible for than by memorizing syntax.
SELECT picks columns, FROM names the table, WHERE filters, JOIN combines tables, ORDER BY sorts.
Operating the form and watching the output makes those correspondences visible naturally.
Once comfortable, try hand-editing the generated queries. Formatting the result with the SQL Formatter gives you readable samples worth keeping.
One caveat worth learning early: the order you write clauses in is not the order the database evaluates them — which is why WHERE cannot see an alias defined in SELECT. The SQL clause order reference maps out both orders.
Build INSERT, UPDATE and DELETE too
The “Change data” section at the bottom uses the tables and columns from your query as suggestions and builds statements that add, update or delete rows.

- INSERT: enter columns and values like a table. “Add row” produces a multi-row
VALUES, and adding a column keeps the rows aligned. Tick “Insert the result of the query above” to get anINSERT … SELECTthat reuses theSELECTyou built - When a row with the same key exists (upsert): choose “Ignore it” or “Update it”. PostgreSQL and SQLite use
ON CONFLICT (key) DO UPDATE SET … = EXCLUDED.…/DO NOTHING(SQLite’s ignore isINSERT OR IGNORE); MySQL usesON DUPLICATE KEY UPDATE … = VALUES(…)/INSERT IGNORE - UPDATE / DELETE: set the
SETcolumns and values and theWHERE(AND/OR,IN,LIKE,IS NULL). Without aWHEREyou get a warning that every row is affected - UPDATE / DELETE with a join: enter the table and columns to join, and PostgreSQL and SQLite get
UPDATE … FROM/DELETE … USING, while MySQL getsUPDATE … JOIN/DELETE t FROM … JOIN(SQLite has no joinedDELETE, so you get a warning). A value written likeo2.statusis a column reference - CREATE VIEW / TABLE AS: turns the query above into
CREATE [OR REPLACE] VIEW,MATERIALIZED VIEW(PostgreSQL) orCREATE TABLE … AS - Values are quoted automatically.
NULL,TRUE,FALSEandNOW()are kept as they are; wrap a value in quotes to get the string'NULL'
Your input is saved automatically in the browser and never sent to a server.
Your unfinished query is saved automatically
The query you are building (tables, joins, conditions, aggregates, GROUP BY, HAVING, ORDER BY, LIMIT, CTEs, UNION and window functions) is saved automatically in this browser. Even if you close the page, you can pick up where you left off next time. “Clear” returns to the starting query, and you can also delete the saved data, or export and import it as JSON (handy for moving to another browser or device). Nothing is sent to a server.
FAQ
Can complex SQL be completed with the builder alone?
Beyond basic SELECT, WHERE and JOIN, it can build AND / OR, BETWEEN, EXISTS, aggregation (GROUP BY / HAVING), ORDER BY, LIMIT / OFFSET, DISTINCT, one-level subqueries, subqueries in FROM, window functions, UNION / UNION ALL and WITH (CTEs). Database-specific functions, SQL that needs performance tuning and statements other than SELECT should be written by hand after generation and reviewed.
Is it suitable for SQL beginners?
Yes. Because you can watch the SQL take shape as you fill in each field, it works as a learning tool — especially for comparing JOIN types and condition expressions.
How does the builder decide whether to quote a value?
Numbers that can be written in decimal (such as 20 or -1.5) are output as they are; anything else is wrapped in single quotes automatically. A number with a leading 0 (007) is treated as a string, and a value you already quoted isn’t quoted twice. A ' inside a value is escaped as ''. LIKE is always a string, IN checks each comma-separated value, and IS NULL doesn’t use the value.
Are my table names and conditions sent to a server?
No. The DevToolKits SQL Builder runs in your browser and generates SQL locally, without transmitting your input.
Summary
A SQL builder turns SQL from “something you memorize and type” into “something you assemble from organized conditions”.
When SELECT or JOIN syntax slows you down, draft the skeleton in the Visual SQL Builder, then format, review, and run.
