-- Online SQL Editor

SELECT first_name, age
FROM People;

About This SQL Editor

SQL is declarative: you describe the result you want and the query planner decides how to produce it. That is why two queries that look similar can differ by orders of magnitude in speed, and why understanding what the planner does matters more than memorising syntax.

The editor highlights keywords, strings and identifiers and helps keep long queries readable. It does not connect to a database or execute anything.

The joins, and the order things actually happen

SQL syntax reference
Syntax What it does
INNER JOIN Only rows with a match on both sides.
LEFT JOIN All rows from the left, with NULLs where the right has no match.
FULL OUTER JOIN All rows from both sides, NULLs where either has no match.
CROSS JOIN Every combination. Usually a mistake when it appears by accident.
ROW_NUMBER() OVER (PARTITION BY x ORDER BY y) Window function - ranks within a group without collapsing rows.
WITH recent AS (SELECT ...) Common table expression. Names a subquery and makes the query readable.
COALESCE(a, b, 0) First non-NULL value.
GROUP BY ... HAVING count(*) > 1 HAVING filters groups; WHERE filters rows before grouping.

What trips people up

  • Logical execution order is not written order. It runs FROM, then JOIN, WHERE, GROUP BY, HAVING, SELECT, then ORDER BY. That is why you cannot use a SELECT alias in WHERE but can in ORDER BY.
  • NULL is not a value. NULL = NULL is not true, it is unknown. Use IS NULL. Aggregates skip NULLs, and COUNT(column) therefore differs from COUNT(*).
  • A WHERE clause on the right table turns a LEFT JOIN into an INNER JOIN, because the NULL rows fail the condition. Put the condition in the ON clause instead.
  • A function on an indexed column disables the index. WHERE YEAR(created_at) = 2026 scans; WHERE created_at >= '2026-01-01' uses the index.
  • String concatenation is not parameterisation. Building SQL from user input is how injection happens. Use bound parameters, always.

Your Code Never Leaves Your Browser

The editor is JavaScript running in this tab. Nothing you type is posted to a server, stored, logged or associated with you, and there is no account and no autosave. That makes it safe to paste a snippet from a private codebase in order to read it with highlighting. The trade-off is that nothing persists either — refresh the page and your content is gone, so copy anything you want to keep.

Frequently Asked Questions

Can I run a query here?

No - there is no database connection. This is a text editor for writing and formatting SQL, so nothing you type is executed or sent anywhere.

Is SQL the same across databases?

The core is standardised and portable, but every engine adds its own dialect. Date functions, string functions, upserts, pagination and window function support all vary between PostgreSQL, MySQL, SQL Server, Oracle and SQLite.

What is the difference between WHERE and HAVING?

WHERE filters individual rows before grouping; HAVING filters the groups afterwards, which is why HAVING can reference aggregates such as COUNT(*) and WHERE cannot.

Editors for Other Languages

Same editor, configured for a different language, each with its own syntax reference.