The SQL mistakes that survive longest are not the dramatic ones. A misspelled table name fails loudly and gets fixed in a minute. A missing comma is quieter: in many dialects it does not break the query at all, because the two column names you placed side by side are read as one column and its alias. The query runs, the report ships, and the numbers under one heading belong to a different column than everyone assumes. A missing closing bracket hides inside a long line, and any error message points at wherever the parser gave up, not at the bracket you forgot.
Both faults share one hiding place: the single line. This guide shows how laying a query out with the free SQL Formatter on Ovatly moves them into the open: not by detecting them, but by giving each item its own line and each clause its own depth.
Contents
- Quick answer
- The missing comma: two columns become one
- The unclosed bracket: indentation gives it away
- How to check a query with the SQL Formatter, step by step
- Worked example: a missing comma, before and after
- Limitations: formatting is not validation
- Common mistakes
- FAQs
- Conclusion
Quick answer
Paste your query into the SQL Formatter, choose your dialect, and press Format SQL. Keywords come back in upper case, clauses land on their own lines, and each select item gets a line of its own. A missing comma then shows up as two names sharing a line where every other item has a line to itself, and an unclosed bracket shows up as indentation that stays one level too deep for the rest of the query. The tool flags neither fault; the layout makes both obvious.
The missing comma: two columns become one
On one line, every character looks like every other character: your eye slides along the commas without registering the gap where one is absent. Formatting changes the unit of reading from the line to the item, so your eye stops reading characters and starts reading shape, and a line that breaks the pattern is visible at a glance.
In a select list, a comma is the only thing separating one item from the next. Leave it out and the two names do not collide; they combine. In many dialects, name email in a select list is a complete, valid instruction: return the name column and label it email. The database has no way to know you meant two columns, because what you wrote is a legitimate request for one.
The consequences are easy to miss downstream. The result set has one fewer column than expected, its heading is the second name rather than the first, and any report built on the headings inherits the confusion. Nothing errors at any stage, which is why the fault survives review: the logic reads correctly at a glance.
Formatted, the same list cannot hide. The formatter places each item on its own line, and an alias pair is the one line carrying two names. Among single-item lines, that doubled line is visibly longer and different, and it draws the eye before any checking begins.
The unclosed bracket: indentation gives it away
Brackets fail differently. A missing closing bracket does not merge two things into one; it swallows everything after it into a group that never ends. Inside a one-line query, that is invisible: there is no visual difference between text inside the group and text after it.
Indentation supplies the difference. Lines inside a bracketed group sit deeper than the lines outside it, and the closing bracket brings the depth back. Leave the bracket unclosed and the depth never returns: the conditions, and often the clauses after them, all sit one level deeper than they should, right to the end of the statement. You do not need to count brackets, only notice that the query drifts deeper and never comes back, a shape judgement your eye makes instantly on formatted code.
How to check a query with the SQL Formatter, step by step
- Open the SQL Formatter and paste your SQL statement into the input box.
- Choose the dialect your database uses. The tool covers eight dialects, including PostgreSQL, MySQL and SQL Server.
- Press Format SQL.
- Read the select list first: one item per line, unless you wrote an alias on purpose. Then read the indentation: each group should open, sit deeper, and come back.
- Copy or download the formatted query once it reads cleanly.
Worked example: a missing comma, before and after
Here is a routine customer query from application code:
select name email, region, created_at from customers where status = 'active'
Read it quickly and nothing looks wrong: there are commas in it, the clauses are all present, and the eye accepts it. Now the same statement after formatting:
SELECT
name email,
region,
created_at
FROM
customers
WHERE
status = 'active'
Three items were requested. Two lines hold one item each; the first holds two names, because without a comma the formatter received one item, a column with an alias, and laid it out as one. That shared line is the fault, made visible. The fix is a single character, and once the comma is restored, the list formats into four honest lines.
The bracket version works the same way. Take a filtered query whose condition opens a bracket that never closes:
select name, region from customers where (status = 'active' and region in ('north', 'south') order by name
Formatted, the lines following the opening bracket stay indented as members of the group, and the ordering clause sits at that deeper level too, grouped with the conditions instead of standing as its own clause. The drift is the signal: something opened and never closed.
Limitations: formatting is not validation
Be clear about what happened above. The formatter did not find either fault, underline it or warn about it. It laid out exactly the statement it was given, including the faults. A formatter is not a validator or a linter, and it will happily format a query that is wrong in a dozen ways, as long as the statement is complete enough to lay out.
It also cannot run your query: with no database connection, it cannot tell you whether the query will execute or return the rows you expect. A query can be beautifully formatted, free of missing commas, and still wrong: wrong table, wrong filter, wrong join. Formatting earns you a readable statement; checking that the statement is correct remains your job, and the readable version makes that job considerably easier. A badly unfinished statement may fail to format at all, which is itself a clue, but a starting point for your own inspection rather than a diagnosis.
Common mistakes
- Trusting a query because it ran. The missing-comma fault produces no error. A successful run proves the syntax was accepted, not that the columns are the ones you asked for.
- Reading the formatted output at the same speed as the original. Scan the select list line by line and check that the indentation steps in and out.
- Picking the wrong dialect. Syntax such as MySQL backticks or T-SQL brackets only parses correctly in its own dialect. A strange result often means the selector, not the query, is wrong.
- Expecting the formatter to repair the fault. It changes layout and keyword case only. The missing comma and the missing bracket are yours to add.
- Checking only the select list. Bracket faults live in conditions and subqueries. Follow the indentation through the whole statement.
FAQs
Does the SQL Formatter find errors in my query? No. The formatter lays your query out; it does not validate it, and it has no database connection, so it cannot tell you whether the query will run. Your eye does the spotting.
Why does a missing comma not cause an error? In many dialects, two names side by side in a select list are read as a column and its alias. Written as name email, the item asks for the name column displayed under the heading email: valid syntax, so the database runs it without complaint.
Does formatting change what the query does? No. It changes layout and keyword case only. Identifiers, values and string literals are left exactly as written, and the statement your database receives is equivalent.
Why did my query fail to format? Usually an unfinished statement or syntax from a different dialect. Check the dialect selector matches your database. Some syntax, like MySQL backticks or T-SQL brackets, only parses in its own dialect.
Can formatting help with brackets as well as commas? Yes, in a different way. A missing closing bracket leaves the lines after it indented as though still inside the group. When the indentation never returns to the level you expect, the unclosed bracket is the first thing to look for.
Conclusion
A missing comma and a missing bracket survive because a one-line query gives them nowhere to stand out. Lay the statement out with the SQL Formatter and the shape of the query does the exposing: one doubled line in the select list, one stretch of indentation that never comes back. For the other half of everyday SQL work, sending readable queries to colleagues, see the companion guide on how to format SQL for a report request from a teammate, and browse the rest of the series in the Developer Tools guides archive.