SQL Query Generator
Fill in a few fields and get a clean, ready-to-run SQL statement. Choose your database and the syntax details, like pagination and auto-increment, are handled for you.
- Free
- No sign-up
- Runs in your browser
Everything runs in your browser. What you type here is never uploaded, stored or sent anywhere.
What is a SQL query generator?
A SQL generator is a form that writes the statement for you. You say which table, which columns and which conditions, and it produces valid SQL with the quoting, commas and clause order already correct. It is a quick way to get a first draft, to check the syntax for a database you do not use every day, or to avoid the small typos that make a query fail.
The syntax differences between databases are what usually trip people up, so the generator handles them. Pagination becomes LIMIT and OFFSET on MySQL, PostgreSQL and SQLite, but TOP or OFFSET ... FETCH on SQL Server. Auto-increment is AUTO_INCREMENT on MySQL, SERIAL on PostgreSQL, AUTOINCREMENT on SQLite and IDENTITY on SQL Server.
Text values are escaped for you, and you can switch on placeholders to get a prepared statement for use in code. Once you have a query, tidy it with the SQL Formatter, or turn a spreadsheet into INSERT statements with the CSV Converter.
How to generate a SQL query
- Pick your database, then choose the statement type: SELECT, INSERT, UPDATE, DELETE or CREATE TABLE.
- Enter the table name and fill in the fields for that statement. The SQL on the right updates as you type.
- Add conditions with + Add condition. For a join, add a row and write the join condition.
- Read the warnings under the output. They flag things like an
UPDATEwith noWHERE. - Copy the SQL or download it as a
.sqlfile. Test it on a copy of your data first.
Good for
- Drafting a query quickly, then refining it by hand.
- Checking how a statement is written in a database you rarely use.
- Creating a table definition with the correct data types for MySQL, PostgreSQL, SQLite or SQL Server.
- Generating parameterised queries (
?,$1,@p1) to paste into application code. - Learning SQL by seeing how each field changes the statement.
Frequently asked questions
Is the generated SQL safe from SQL injection?
Text values you type are escaped, and you can tick Use placeholders to generate a prepared statement with ?, $1 or @p1. In application code, always use placeholders and pass user input as parameters rather than building SQL strings by hand.
Which databases are supported?
MySQL and MariaDB, PostgreSQL, SQLite and SQL Server. The differences covered include identifier quoting, pagination, auto-increment columns and data type names.
Why does it warn me about UPDATE and DELETE?
An UPDATE or DELETE with no WHERE clause changes every row in the table. That is almost never what you want, so the tool points it out. Always run such statements on a backup or inside a transaction first.
How do I write a text value that looks like a number?
Put it in quotes. A value like 007 typed in quotes ('007') stays text, while 7 without quotes is treated as a number.
Can it generate joins and subqueries?
It supports INNER, LEFT, RIGHT, FULL and CROSS joins with your own conditions, plus GROUP BY, HAVING, ORDER BY, LIMIT and OFFSET. For subqueries and window functions, write the query by hand and use the SQL Formatter to keep it readable.
Does it run the query?
No. It only writes the SQL. Nothing is sent to a database or a server, and nothing you type leaves your browser.
