SQL Comments Explained: Two Syntaxes and the Formatting Habit That Prevents Query Breaks
SQL supports two comment styles: double dashes (--) hide the remainder of a single line, while slash-star markers (/* */) wrap multi-line blocks and only end when a closing mark appears. Both syntaxes work consistently across major databases including PostgreSQL, MySQL, BigQuery, and Snowflake. A common pitfall arises when commenting out a line that carries trailing punctuation — such as a comma after a column name or an AND at the end of a WHERE condition — leaving the line above it syntactically broken. Data analyst Michael Nocito explains that placing commas and AND keywords at the start of each new line, rather than the end, prevents this issue entirely. With that single formatting habit, any line can be safely commented out without corrupting the surrounding query.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in