SQL Generator

Build SELECT queries with filters, joins and sorting, or CREATE TABLE statements — with identifiers and values safely escaped.

100% FreeNo sign-upPrivate — runs in your browser
Copied to clipboard

How to use this tool

1
Choose the mode

SELECT query builder, or CREATE TABLE.

2
Enter table and columns

Leave columns blank for *. Column and table names must be valid identifiers.

3
Add filters, one per line

e.g. age > 18 or city IN NYC, LA. Sorting and LIMIT are optional.

4
Generate and copy

The SQL is shown with string values safely quoted (single quotes doubled).

Formula & worked example

SELECT [DISTINCT] columns FROM table [JOIN … ON a = b] [WHERE conditions AND …] [ORDER BY column ASC|DESC] [LIMIT n]; Values are escaped: strings are single-quoted with embedded quotes doubled, numbers pass through, TRUE/FALSE/NULL are emitted as SQL literals.

Table users, columns id, name, filter age > 18, order name DESC, limit 10 gives: SELECT id, name FROM users WHERE age > 18 ORDER BY name DESC LIMIT 10;

Limitations — read this before you rely on it

This builds standard SQL for common cases. It does not support subqueries, window functions, GROUP BY/HAVING, or dialect-specific syntax beyond the generic form — and it cannot check your query against a real database schema. Always review generated SQL before running it, especially against production data.

Frequently asked questions

Strings are wrapped in single quotes and any single quote inside is doubled (O'Brien → 'O''Brien'), which is the SQL standard. Numbers, TRUE/FALSE and NULL are emitted bare.

To prevent injection through names: only letters, digits and underscores (optionally schema.table) are accepted, so a name cannot smuggle in extra SQL.

This tool builds queries and table definitions. The INSERT Generator turns rows of data into INSERT statements — a different job.

Yes — INNER, LEFT, RIGHT and FULL joins with a single ON equality condition each, via the builder's join options in code; the page form covers the common single-table case.

No — this page has no database. Copy the SQL into your database client.