QA
Beginner LevelSQL & MySQL

What is the syntax for single-line and multi-line comments in SQL?

❓ Interview Prompt: Explain SQL comment syntax: single-line (`--` and `#`) and multi-line (`/* ... */`) block comments.

SQL supports both single-line and multi-line comments to document query logic:

•
Single-Line Comment: '-- Comment text' (Requires a space after double-dashes) or '# Comment text' (in MySQL).
•
Multi-Line Block Comment: '/ Comment text spanning multiple lines /'.

Code Implementation Example

sql
-- Single-line comment explaining filter criteria
SELECT id, email
FROM users /* Multi-line inline comment */
WHERE status = 'ACTIVE'; -- Filter active users only
💡Documenting query logic with single-line and multi-line comments.
🎯 Interview Key Takeaway

Use single-line and block comments to document complex query logic and business rule constraints.

#SQL#Comments#Syntax#Beginner
Back to all SQL & MySQL Questions→

More SQL & MySQL Interview Questions

Beginner LevelSQL & MySQL

How do B-Tree Indexes work in SQL/MySQL and how do you optimize slow queries using EXPLAIN?

Beginner LevelSQL & MySQL

How do SELECT, WHERE, ORDER BY, and LIMIT clauses filter relational datasets?

Beginner LevelSQL & MySQL

What are INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN?