In SQL, comments are used to add notes or explanations to your code without affecting its execution. There are two main ways to write comments:
1. Single-line comment: Use — before the comment text. Everything after — on that line is ignored.
— This is a single-line comment
SELECT * FROM users;
2. Multi-line comment: Use /* to start the comment and */ to end it. This can span multiple lines.
/* This is a
multi-line comment */
SELECT * FROM products;
Both are useful for explaining complex queries or temporarily disabling parts of your code.