How to use
- Paste the query into the SQL input box. It starts with a sample that contains several mistakes.
- Pick the SQL dialect that matches your database. Your choice is remembered in this browser.
- Read the errors and warnings in the table with their line, column and the code on that line.
- Fix the errors and the result refreshes. A formatted copy with uppercase keywords appears below for you to copy.
You can paste several statements separated by semicolons. No database is contacted, so it cannot check that tables or columns actually exist.
What is checked
| Group | Checks | Severity |
|---|---|---|
| Quotes and comments | Unclosed strings ('), identifiers (", `, [ ]), comments (/* */) and PostgreSQL $$ strings |
Error |
| Parentheses | Unbalanced ( and ) |
Error |
| Commas | A comma left before FROM or ), doubled commas |
Error |
| Empty clauses | No columns after SELECT, nothing after WHERE, FROM, ORDER BY or LIMIT |
Error |
| Clause order | FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT out of order, BY missing after ORDER |
Error |
| INSERT | Listed column count differs from the VALUES count (every row is checked) |
Error |
| UPDATE | No SET clause |
Error |
| Risky habits | UPDATE or DELETE without WHERE, = NULL comparison, JOIN without ON, SELECTs joined without a semicolon |
Warning |
| Typos | A statement starting with an unknown word like SELCT suggests the closest keyword |
Warning |
| Dialect | Syntax that the chosen dialect does not accept | Warning |
Sample result
Checking the sample in the box as MySQL gives 2 errors and 3 warnings:
- Line 1, column 48: nothing follows the comma after
order_count(error) - Line 3:
LEFT JOIN orders ohas no ON condition (warning) - Line 4:
u.status = NULLshould use IS NULL (warning) - Line 8:
UPDATE users SET status = 'inactive'has no WHERE, so every row changes (warning) - Line 10: 3 columns are listed but 2 values are given (error)
Dialect differences
The same intent is written differently by each database. The items below are flagged when they do not fit the selected dialect.
| Goal | MySQL, MariaDB | PostgreSQL | SQL Server | Oracle |
|---|---|---|---|---|
| First N rows | LIMIT n |
LIMIT n |
TOP n |
FETCH FIRST n ROWS ONLY |
| Quote identifiers | Backticks | Double quotes | Double quotes or [ ] |
Double quotes |
| Case-insensitive match | Mostly by default collation | ILIKE |
Depends on collation | Compare with UPPER() |
| Update on duplicate | ON DUPLICATE KEY UPDATE |
ON CONFLICT ... DO UPDATE |
MERGE |
MERGE |
| Auto-increment column | AUTO_INCREMENT |
SERIAL, IDENTITY |
IDENTITY |
IDENTITY (12c and later) |
Strings use single quotes in every dialect. Double quotes also read as a string in the default mode of MySQL and MariaDB, but databases such as PostgreSQL treat them as a column name and fail with errors like column "x" does not exist.
NULL and changes without WHERE
WHERE b = NULL never selects a row, because comparing with NULL using = gives UNKNOWN, neither true nor false. Use IS NULL. An = that assigns, as in UPDATE t SET b = NULL, is fine and is not flagged.
An UPDATE or DELETE without WHERE changes the whole table. That is sometimes intended, so it is a warning and not an error. On a production database it is a good habit to run the same condition as a SELECT first and confirm the row count.
Frequently asked questions
If this passes, will the query run?
There is no guarantee. It only finds visible mistakes in quotes, parentheses and clause structure. Missing tables or columns, type mismatches, permissions and function argument errors are reported by the database at run time.
Can I use it instead of EXPLAIN?
No. EXPLAIN is the database’s own interpretation of the query. This tool is for filtering out common mistakes quickly where no database is available.
Does it check stored procedure and trigger bodies?
Statements are split on semicolons, so each statement inside BEGIN ... END is looked at, but procedural syntax is not understood and false alarms are possible.
How do I make the query easier to read?
Use the formatted output here, or the SQL Formatter for indentation, keyword case and minify options.
Related tools: SQL Formatter, CSV SQL Query, SQLite Viewer, XML Validator, JSON Formatter.
No database is contacted, and your SQL is checked in your browser only and never sent to a server.