artisan.dev

SQL Query Builder

Where Clauses

No conditions — query will affect all rows

Generated SQL
SELECT *
FROM <table>;

How to build SQL queries visually

This SQL query builder generates clean, readable SQL from a form. Pick a statement type — SELECT, UPDATE, DELETE, TRUNCATE or JOIN — fill in the table, columns and conditions, and the query is written for you with consistent formatting and syntax highlighting.

It is useful for drafting ad-hoc queries, teaching or learning SQL syntax, and avoiding typos in WHERE clauses when you're in a hurry. The builder only writes SQL; it never connects to a database, and nothing you type leaves your browser.

How to use the SQL builder

  1. Choose a tab for the statement type.
  2. Enter the table name and, for SELECT, the columns you want (leave empty for *).
  3. Add WHERE conditions. Each condition has a column, an operator (=, !=, >, <, >=, <=, LIKE, NOT LIKE, IN, IS NULL, IS NOT NULL) and a value, and conditions can be chained with AND or OR.
  4. For SELECT and JOIN, optionally set ORDER BY with direction and a LIMIT.
  5. For UPDATE, add the SET column/value pairs. For JOIN, choose INNER, LEFT, RIGHT or FULL OUTER, the two tables and the ON condition that links them (e.g. orders.user_id = users.id).
  6. Copy the generated query into your SQL client.

Values are quoted for you: numbers, NULL, TRUE and FALSE are left bare, text is wrapped in single quotes, and IN lists are wrapped in parentheses. For example:

SELECT id, email, created_at
FROM users
WHERE status = 'active'
  AND created_at >= '2026-01-01'
ORDER BY created_at DESC
LIMIT 50;

Choosing the right JOIN

JoinReturns
INNER JOINOnly rows with a match in both tables
LEFT JOINAll rows from the left table, with NULLs where the right table has no match
RIGHT JOINAll rows from the right table, with NULLs where the left has no match
FULL OUTER JOINAll rows from both tables (not supported natively in MySQL — emulate with LEFT JOIN … UNION … RIGHT JOIN)

A frequent bug: filtering the right-hand table of a LEFT JOIN in the WHERE clause (WHERE orders.status = 'paid') silently turns it into an inner join, because rows with no order have NULL status. Put that condition in the ON clause instead if you want to keep unmatched rows.

Safety checks before you run it

  • UPDATE and DELETE without WHERE affect every row. Run the same conditions as a SELECT COUNT(*) first, and use a transaction (BEGIN; … ROLLBACK;) when trying a change on production data. MySQL's --safe-updates mode blocks key-less updates entirely.
  • TRUNCATE can't be filtered and, in MySQL, can't be rolled back — it removes all rows and resets auto-increment counters.
  • = NULL never matches. Use IS NULL / IS NOT NULL; the builder offers them as operators for this reason.
  • LIKE with a leading wildcard ('%term') can't use a normal B-tree index and scans the table.
  • Don't paste user input into SQL in application code. The builder is for writing queries by hand. In applications, always use parameterised queries or an ORM to prevent SQL injection.

Dialect notes

The output is standard SQL that runs as-is on PostgreSQL, MySQL/MariaDB and SQLite for the statement types covered. Differences to watch: SQL Server uses TOP n or OFFSET … FETCH instead of LIMIT; identifiers that are reserved words or contain spaces need quoting — "name" in PostgreSQL and standard SQL, backticks in MySQL, [name] in SQL Server.

Frequently asked questions

Does the SQL builder connect to my database?

No. It only generates SQL text in your browser. Copy the query into your own client — psql, MySQL Workbench, DBeaver, DataGrip — to run it.

Which databases does the generated SQL work with?

The SELECT, UPDATE, DELETE, TRUNCATE and JOIN statements use standard syntax that works in PostgreSQL, MySQL, MariaDB and SQLite. SQL Server needs TOP instead of LIMIT, and MySQL doesn't support FULL OUTER JOIN.

How do I write an IN condition?

Choose the IN operator and enter comma-separated values, e.g. 'paid', 'shipped' or 1, 2, 3. The builder wraps them in parentheses.

Related tools