01What is SQL Query Builder?
Sometimes you know what data you want but not how the SELECT should look, or you just want the clauses in the right order without typing them. This builder gives you a form for each part of a SELECT statement and writes the formatted SQL as you fill it in. You start with a Table and an optional Alias, and you can tick DISTINCT. Under Columns, each row takes a column name, an optional aggregate (COUNT, SUM, AVG, MAX or MIN) and an optional alias. Under JOINs you pick INNER, LEFT, RIGHT or FULL, then give a table, an alias and the ON condition. WHERE rows take a column, an operator and a value, plus an AND or OR connector to the row before. The operators are =, !=, >, <, >=, <=, LIKE, IN, IS NULL, IS NOT NULL and BETWEEN. Last come GROUP BY, HAVING, ORDER BY with ASC or DESC, LIMIT and OFFSET. The clause order follows standard SQL: SELECT, FROM, JOIN, WHERE, GROUP BY, HAVING, ORDER BY, then LIMIT and OFFSET. The code adds a few guard rails. Empty column and WHERE rows are dropped. IS NULL and IS NOT NULL never get a stray value. An alias that is not a plain identifier, like Email Address, is wrapped in double quotes, as the SQL standard expects for delimited identifiers. LIMIT and OFFSET are only written when they are whole numbers. OFFSET is also skipped unless LIMIT is set, because MySQL and SQLite do not accept OFFSET on its own. A quick example. Set the table to users with alias u, add a WHERE row u.deleted_at IS NULL, then an OR row u.role = 'admin', and order by u.id DESC. You get a five-clause query ending in ORDER BY u.id DESC and a semicolon. If you type 20 in OFFSET with LIMIT empty, the OFFSET line simply does not appear. Now the honest part. Values and ON conditions are pasted exactly as you type them. Strings need their own single quotes, and IN lists need their own parentheses. Mixed AND and OR rows are not wrapped in parentheses, so you need to add them yourself when the precedence matters. A JOIN with an empty ON field is written with no ON clause at all. Most databases need one for these join types, so fill it in. Nothing here connects to a database or checks that your tables exist. The query is only text built in the page. In application code, pass user values through your driver's placeholders rather than gluing them into this SQL.
Developers, analysts and SQL learners who want a correctly ordered SELECT with joins, filters and grouping without writing every clause from memory. The tool runs entirely in your browser, so your data never leaves your device.
02How to use SQL Query Builder
- Fill in Table and Alias, and tick DISTINCT if you need unique rows.
- Use Add column to list Columns, then pick an Aggregate and an Alias where needed.
- Use Add join for JOINs (Type, table, alias, ON condition) and Add condition for WHERE rows with Connector, Operator and value.
- Fill in GROUP BY, HAVING, ORDER BY with Sort direction, LIMIT and OFFSET.
- Read the Generated SQL and click Copy, or start over with Reset.
03Worked examples
- Input:
Simple SELECT preset (users u; id, email, name; u.active = true AND u.created_at > '2024-01-01'; ORDER BY u.created_at DESC; LIMIT 50) - Result:
SELECT id, email, name FROM users u WHERE u.active = true AND u.created_at > '2024-01-01' ORDER BY u.created_at DESC LIMIT 50; - Input:
JOIN preset (orders o INNER JOIN users u, LEFT JOIN products p, aliased columns) - Result:
SELECT o.id AS order_id, u.name AS customer, p.name AS product, o.total FROM orders o INNER JOIN users u ON o.user_id = u.id LEFT JOIN products p ON o.product_id = p.id WHERE o.status = 'completed' ORDER BY o.created_at DESC LIMIT 100; - Input:
WHERE u.deleted_at IS NULL, OR u.role = 'admin'; ORDER BY u.id DESC; LIMIT empty, OFFSET 20 - Result:
SELECT * FROM users u WHERE u.deleted_at IS NULL OR u.role = 'admin' ORDER BY u.id DESC; - IS NULL takes no value, and OFFSET is dropped because LIMIT is empty.
- Input:
DISTINCT; u.email AS Email Address, COUNT(u.id) AS n; GROUP BY u.email; LIMIT 10, OFFSET 20 - Result:
SELECT DISTINCT u.email AS "Email Address", COUNT(u.id) AS n FROM users u GROUP BY u.email LIMIT 10 OFFSET 20; - The alias with a space is double-quoted. The plain alias n stays bare.
- Input:
u.status IN ('active','trial') AND u.age BETWEEN 18 AND 30; LIMIT ten - Result:
SELECT * FROM users u WHERE u.status IN ('active','trial') AND u.age BETWEEN 18 AND 30; - Values are inserted as typed. LIMIT is skipped because "ten" is not a whole number.
04Common use cases
- Drafting a revenue-per-customer report with SUM, GROUP BY and HAVING before pasting it into DBeaver or pgAdmin
- Building a paginated admin list query with ORDER BY, LIMIT 50 and OFFSET for an API endpoint
- Showing a support teammate how a filter like "active users created after January" maps to WHERE rows
- Practising the difference between INNER and LEFT JOIN in a database course
- Sketching the SQL behind a Metabase or Grafana panel before writing it by hand
- Getting a quoted alias like "Email Address" right for a CSV export query
05Tips
- Type string values with their quotes, like 'completed'. A bare completed is treated as a column name by the database.
- For IN, type the whole list with parentheses, such as ('active','trial'). For BETWEEN, type 18 AND 30 in the value field.
- AND binds tighter than OR. If you mix them, add parentheses in the copied SQL so the filter means what you think.
- ORDER BY can use a column alias such as total_spent, which most databases accept. HAVING usually cannot, so repeat the aggregate there.
- If OFFSET seems ignored, check LIMIT. The builder only writes OFFSET when LIMIT has a whole number.
06Related concepts
SELECT statement, JOIN, GROUP BY, aggregate functions, pagination.
Frequently Asked Questions
What is SQL Query Builder?
SQL Query Builder is a free, browser-based developer tool on AIDToolStack. Visual SQL query builder It requires no installation or sign-up and works entirely in your browser.
Is SQL Query Builder free to use?
Yes. No sign-up, no fees and no usage cap.
Does SQL Query Builder store my data?
No. It runs in your browser; nothing is uploaded.