SQL
4 min read
BEGINNER
Statements and comments
Quick AnswerA statement is a complete SQL instruction. A semicolon separates statements in scripts; some clients accept a single statement without it. Newlines and indentation usually make SQL easier to read rather than ending a statement. Comments explain intent without becoming executable instructions.
Core idea
A statement is a complete SQL instruction. A semicolon separates statements in scripts; some clients accept a single statement without it. Newlines and indentation usually make SQL easier to read rather than ending a statement. Comments explain intent without becoming executable instructions.
Minimal example
sql
-- List product namesSELECT name FROM products ORDER BY id;Expected rows (in order):
text
NotebookPenBagPencilHow it works
The double hyphen begins a line comment. A block comment uses /* ... */. A comment marker inside a quoted string is text, not a comment. Nested block comments are dialect-dependent.
Practical example
sql
SELECT /* price in cents */ price_cents FROM products ORDER BY id;Expected rows (in order):
text
3501502400100Practice
Add a comment explaining why prices are stored in cents. Keep the query result unchanged.