Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchUse -- for a line comment and /* ... */ for a block comment. The main gotchas are that MySQL requires whitespace after --, and a line comment hides everything else on that line—including punctuation your query may need. Comment rules also vary by database, so check the dialect before relying on nesting or assuming every comment is ignored.
Two ways to write a SQL comment
Line comments with --
In PostgreSQL, MySQL, SQLite, SQL Server (Transact-SQL), and Oracle, -- marks a line comment. The comment runs to the line ending or, where applicable, the end of the input. In MySQL, put whitespace or a control character after the second dash; the details and example are covered below.
As an Amazon Associate I earn from qualifying purchases.
-- The rest of this line is a comment
SELECT customer_id, total
FROM orders;
For portability, write a space after the dashes and put the comment on its own line when possible.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Block comments with /* ... */
A block comment starts with /* and ends at */. It can span lines in PostgreSQL, MySQL, SQLite, and Oracle; SQL Server also supports block comments.
#1 Best Overall
/* This comment can span lines.
Keep the closing marker visible. */
SELECT customer_id, total
FROM orders;
Comments can appear inside a statement where whitespace is allowed, but avoid placing one where it could obscure punctuation you need to check:
SELECT customer_id, /* describes the next column */ total
FROM orders;
Why -- can behave differently in MySQL
MySQL 8.4 recognizes -- as a comment opener only when the second dash is followed by whitespace or a control character. Other engines can have different parsing rules, so do not generalize this MySQL-specific requirement to every database. See the MySQL 8.4 Reference Manual.
This matters in generated arithmetic. The MySQL 8.0 manual gives the example balance=balance--1: the dashes can begin a comment, causing the intended expression after them to be discarded. The result is not the subtraction the writer meant. MySQL’s 8.4 documentation also specifies the whitespace requirement. See MySQL 8.0: “–” as the Start of a Comment.
Recommended Free Tools
Make the operation explicit with spacing and parentheses, for example balance = balance - (-1). This illustrates the intended arithmetic; it is not a substitute for checking how the target database parses the full statement.
How a comment can hide required SQL
A line comment consumes the rest of its line. If a comma, closing parenthesis, join condition, predicate, or statement terminator appears after --, that text is part of the comment too. The next line may then leave an incomplete expression or change how the statement is structured.
SELECT customer_id, -- temporarily omit total,
FROM orders;
Here the comma after total is hidden along with the rest of the line. The remaining statement is not the same as one with a valid second select item. When commenting out a selected expression, inspect the commas and parentheses around it; use a comment on its own line when that is clearer.
Rank #4
Block comments do not nest consistently
Do not assume a block comment can safely contain another block comment. PostgreSQL and Transact-SQL support nested block comments. SQLite says comments do not nest, and MySQL documents nested comments as unsupported and advises avoiding them. Oracle’s cited documentation describes multiline comments but does not establish nested-comment support.
For example, wrapping code that already contains /* ... */ in another block comment can cause the inner closing marker to end the outer comment earlier than expected in SQLite or MySQL. For portable code, avoid nested block comments. Compare the engine-specific documentation: PostgreSQL 18 lexical structure, SQLite comment syntax, Transact-SQL block comments, and the MySQL 8.4 comments reference.
When comments can affect behavior
Ordinary comments are generally treated like whitespace for parsing, but not every comment-shaped sequence is inert. MySQL supports executable comments using forms such as /*! ... */, and comment syntax is also used for optimizer hints such as /*+ ... */. Oracle hints are comments that provide instructions to the optimizer. These are dialect-specific features, not ordinary explanatory comments; see the MySQL 8.4 documentation and Oracle Database 18c SQL Language Reference.
SQL comment behavior by database
| Database and documentation | -- line comment |
/* ... */ block comment |
Nesting or special case |
|---|---|---|---|
| PostgreSQL 18 | Through the end of the line | Supported | Block comments nest; comments are replaced by whitespace before syntax analysis. PostgreSQL documentation |
| MySQL 8.4 | Requires whitespace or a control character after the second dash | Supported | Nested comments are unsupported and should be avoided. /*! ... */ can execute MySQL code; /*+ ... */ is used for optimizer hints. MySQL documentation |
| SQLite | Through the newline or end of input | Supported through the first closing */ |
Comments do not nest and behave like whitespace. SQLite documentation |
| SQL Server (Transact-SQL) | Through the newline | Supported | Nested block comments are supported; an unmatched nested opener produces an error. Line-comment documentation and block-comment documentation |
| Oracle Database 18c | Ends at a line break | Multiline form documented | Hints use comment syntax to give optimizer instructions. SQL*Plus may impose interface-specific blank-line restrictions. Oracle documentation |
This comparison is limited to the comment behavior in the linked documentation; it does not imply these databases share other SQL syntax.
Quick Recap
What to check when a query breaks after commenting
- Identify the database and execution tool. Parser behavior can differ by engine, and a client or script runner may have its own handling.
- Write line comments clearly. Put
--on its own line where practical, and include a space after it; MySQL requires whitespace or a control character after the second dash. - Inspect the rest of the line. Look for commas, closing parentheses, predicates, join conditions, and statement terminators that may have been swallowed.
- Match the block markers. Count the
/*and*/pairs, and do not assume nested comments are supported. - Check the SQL that remains. In a copy of the statement, remove comments mentally or temporarily and confirm the remaining expressions and clauses are complete. If behavior changes despite ordinary-looking comments, check for executable comments or optimizer hints in that dialect.
- Isolate the statement. Re-run the smallest relevant query in the target engine to pinpoint which comment or surrounding token changes the parse.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →




