Ad space (banner)
🗄️SQL Lessons
Lesson 13 / 50

Writing Comments in SQL

This lesson covers writing comments in SQL, so queries stay understandable when you come back to them later. It's for anyone searching "SQL comment syntax."

A comment is a note for humans that has zero effect on how a statement runs. -- starts a single-line comment (to the end of the line), and /* */ wraps a multi-line comment.

The example mixes a single-line -- create the students table comment with a multi-line /* */ block. Neither affects the query's results at all — they're purely there for whoever reads the code next.

A common early mistake is using the wrong comment symbol out of habit — other languages use // or #, but SQL uses --, which trips up people coming from another language. Writing down "why this condition is here" pays off enormously when you (or a teammate) revisit a complex query months later, and comments are also the standard way to temporarily disable part of a query while debugging.

SQL
OUTPUT

💡 The SQL engine may take a few seconds to load the first time you run code.

Ad space (banner)
Ad space (in-article)