SELECT Query Builder
Choose columns, add INNER, LEFT, RIGHT or FULL joins, build a WHERE clause with AND and OR, and add GROUP BY, HAVING, ORDER BY and row limits in one form.
Build SELECT, INSERT, UPDATE and DELETE queries with a simple form. Add joins, conditions, sorting and limits for MySQL, PostgreSQL, SQL Server, SQLite and Oracle. Fast, free and no signup.
Pick SELECT, INSERT, UPDATE or DELETE and enter the table name.
Add columns, joins, conditions, sorting and limits with simple fields.
Select your database, then copy or download the finished query.
This free online SQL query builder helps you write correct SQL without memorising syntax. Choose a query type, type the table and column names, add joins and WHERE conditions with a few clicks, and the tool generates a clean, formatted statement that you can copy straight into your database client. It works as a SELECT query builder, an INSERT statement generator, an UPDATE query generator and a DELETE query generator, and it adapts the syntax for MySQL, PostgreSQL, SQL Server, SQLite and Oracle. It runs in your browser, needs no signup and never connects to your database.
This free SQL query generator is made for everyday database work: a quick report, a data fix, a migration script or a query you simply cannot remember the syntax for. Fill in the form and the tool writes clean, formatted SQL for MySQL, PostgreSQL, SQL Server, SQLite or Oracle, with the right identifier quotes and row-limit syntax. It works in any modern browser on Windows, Mac, Linux, Android and iPhone, needs no signup, and never connects to your database.
Choose columns, add INNER, LEFT, RIGHT or FULL joins, build a WHERE clause with AND and OR, and add GROUP BY, HAVING, ORDER BY and row limits in one form.
Generate INSERT INTO statements from column and value pairs, UPDATE queries with SET and WHERE, and DELETE queries, with a warning when the WHERE clause is missing.
Pick your database and the builder switches the identifier quotes and the row-limit syntax, such as LIMIT, TOP or FETCH FIRST, so the query runs without edits.
SQL (Structured Query Language) is the standard language for reading and changing data in relational databases such as MySQL, PostgreSQL, SQL Server, SQLite and Oracle. A SQL query builder, also called a SQL generator, creates those statements from a visual form. Instead of remembering the order of clauses and the small differences between databases, you fill in fields and get valid SQL.
A query builder is useful for beginners who are learning SQL, for developers who need a quick statement for a report or migration, and for analysts who want a correct query without writing it from scratch. The generated code is plain SQL, so you can read it, edit it and learn from it.
| Statement | What it does | Example |
|---|---|---|
| SELECT | Reads rows from one or more tables | SELECT id, name FROM users WHERE active = 1; |
| INSERT | Adds a new row to a table | INSERT INTO users (name, email) VALUES ('Ali', 'ali@example.com'); |
| UPDATE | Changes values in existing rows | UPDATE users SET active = 0 WHERE id = 7; |
| DELETE | Removes rows from a table | DELETE FROM users WHERE id = 7; |
A JOIN combines rows from two tables based on a related column, usually a foreign key. Choosing the right join type decides which rows appear in the result.
| Join | Rows returned | Typical use |
|---|---|---|
| INNER JOIN | Only rows that match in both tables | Orders together with their customers |
| LEFT JOIN | All rows from the left table, matches from the right (NULL if none) | All users, including those with no orders |
| RIGHT JOIN | All rows from the right table, matches from the left | All products, including those never ordered |
| FULL JOIN | All rows from both tables (NULL where there is no match) | Finding unmatched rows on either side |
| CROSS JOIN | Every combination of rows from both tables | Generating combinations, such as sizes and colours |
Note that MySQL does not support FULL JOIN. To get the same result there, combine a LEFT JOIN and a RIGHT JOIN with UNION.
The WHERE clause filters the rows that a SELECT, UPDATE or DELETE statement affects. The builder supports the operators that cover most real queries.
| Operator | Meaning | Example |
|---|---|---|
| =, <> | Equal, not equal | status = 'paid' |
| >, <, >=, <= | Greater or less than | price >= 100 |
| LIKE, NOT LIKE | Pattern match with % as a wildcard | name LIKE 'Al%' |
| IN, NOT IN | Matches any value in a list | country IN ('PK', 'IN', 'US') |
| BETWEEN | Within a range, including both ends | age BETWEEN 18 AND 30 |
| IS NULL, IS NOT NULL | Checks for a missing value | deleted_at IS NULL |
Combine several conditions with AND when all of them must be true, or OR when at least one must be true. Remember that NULL is not equal to anything, so use IS NULL instead of = NULL.
SQL clauses must be written in a fixed order, otherwise the database returns a syntax error. The builder always outputs them in the correct sequence:
The core of SQL is the same everywhere, but databases differ in how they quote names and limit rows. This is the reason a query copied from one database often fails in another, and the reason the builder asks for your database first.
| Database | Identifier quotes | Limiting rows |
|---|---|---|
| MySQL / MariaDB | Backticks: `name` | LIMIT 10 OFFSET 20 |
| PostgreSQL | Double quotes: "name" | LIMIT 10 OFFSET 20 |
| SQL Server | Square brackets: [name] | SELECT TOP 10 or OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY |
| SQLite | Double quotes: "name" | LIMIT 10 OFFSET 20 |
| Oracle (12c+) | Double quotes: "name" | OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY |
Quoting identifiers is optional but helpful when a table or column name is a reserved word, such as order or user. In Oracle and PostgreSQL, quoted names become case-sensitive, so quote them only when you need to.
SQL injection happens when untrusted input is pasted directly into a query string, allowing an attacker to change the meaning of the query. The builder escapes single quotes in text values, which is fine for quick manual queries, but applications should use prepared statements. Turn on the question mark placeholders option to generate a query such as SELECT * FROM users WHERE email = ?, then pass the real value separately through your database driver. The database treats bound values as data, never as SQL code.
Most SQL errors come from a few small mistakes. The builder avoids many of them by writing clauses in the right order, but these are worth knowing:
| Error | Usual cause | How to fix it |
|---|---|---|
| Syntax error near LIMIT | LIMIT is not supported in SQL Server or Oracle | Choose the right database in Settings so the builder writes TOP or FETCH FIRST. |
| Ambiguous column name | The same column exists in two joined tables | Prefix the column with a table name or alias, for example u.id. |
| Unknown column | A typo, or the column is a reserved word | Check the spelling and turn on Quote identifiers. |
| No rows returned after a LEFT JOIN with WHERE | A WHERE condition on the right table removes the NULL rows | Move the condition into the JOIN ... ON clause. |
| Column must appear in GROUP BY | A selected column is neither grouped nor aggregated | Add it to GROUP BY or wrap it in COUNT, SUM, MIN or MAX. |
| Comparison with NULL returns nothing | = NULL is never true | Use IS NULL or IS NOT NULL. |
The builder is a web page, so you can create a query on a laptop, a tablet or a phone. Open it in Chrome, Edge, Safari or Firefox, fill in the form and copy the SQL into your database client, such as MySQL Workbench, pgAdmin, SQL Server Management Studio or DBeaver. You can also download the query as a .sql file.
The builder runs in your browser. It does not connect to a database, run your query or upload your table and column names. Still, review every generated statement, test UPDATE and DELETE queries on a copy of your data and keep a backup before changing important tables.
Database work often involves small tasks around the query itself. These free tools can help:
Our SQL query builder is free, fast and works on desktop, tablet and mobile. There is no account, nothing to install and no limit on the number of queries you create. Everything is generated inside your browser, and the tool never connects to your database, so your table names and values stay on your device. Review every generated query and test it on a copy of your data before you run it in production.
Find answers to common questions about building SQL queries, joins, database differences and query safety.
A SQL query builder is a tool that creates SQL statements from a form instead of requiring you to type every keyword by hand. You enter the table, columns, conditions, joins and sorting, and the builder writes a correctly formatted SELECT, INSERT, UPDATE or DELETE statement that you can copy into your database client, script or application.
Choose SELECT as the query type, enter the table name, list the columns you want (leave it empty for all columns) and add one or more conditions in the WHERE section. For each condition pick a column, an operator such as =, LIKE, IN or BETWEEN, and a value. The generated SQL updates instantly, and you can add joins, GROUP BY, ORDER BY and LIMIT in the same form.
It supports MySQL, PostgreSQL, SQL Server, SQLite and Oracle. The tool changes the identifier quotes and the way rows are limited to match your database: LIMIT and OFFSET for MySQL, PostgreSQL and SQLite, TOP or OFFSET FETCH for SQL Server, and FETCH FIRST for Oracle 12c and newer.
An INNER JOIN returns only the rows that have a match in both tables. A LEFT JOIN returns every row from the left table and the matching rows from the right table, with NULL where there is no match. A RIGHT JOIN does the opposite. A FULL JOIN returns all rows from both tables and fills in NULL where one side has no match. MySQL does not support FULL JOIN directly.
It depends on the database. MySQL, PostgreSQL and SQLite use LIMIT with an optional OFFSET. SQL Server uses SELECT TOP n, or OFFSET and FETCH NEXT when you need paging. Oracle 12c and newer use FETCH FIRST n ROWS ONLY. Enter the limit and offset in the form, choose your database, and the builder writes the right syntax.
The builder escapes single quotes in text values, but the safest way to protect an application is to use prepared statements with bound parameters instead of putting values directly in the SQL string. Turn on the question mark placeholders option to generate a query with ? in place of every value, then bind the real values in your code. Never build queries by joining raw user input into SQL.
Yes. It is free, needs no signup and works entirely in your browser. The tool does not connect to a database, does not run your queries and does not upload the table names or values you type, so it is safe to use with your own schema. Always review the generated SQL and test it on a copy of your data before running it in production.
Build SQL queries, generate UUIDs, convert Unix timestamps or format and validate JSON in seconds. Explore free developer tools to build, convert and debug your data in one place.
Explore All Developer Tools →