Introduction Query anatomy: Comments

5. Query anatomy: Comments

SQL as any programming language has the notion of comments – parts of the query that are not a query. If you open the Playground you’ll see the first default query:

-- This is your very first SQL query.
-- It lists all records from the users table: 

FROM users

As you can see the first 2 lines ☝ are just a comment about what the query is doing. Comments are very useful for documentation of hacks/techniques you used in a query so other people (or you in 3 months) can understand what’s going on.

Alternative comments syntax

-- style comments are very handy when you need to comment out just one line. If you want to write a bigger comment you can also use /* ... */ style:

/* This is your very first SQL query.
It lists all records from the users table. */

FROM users

How to use comments in the course

All queries you’ll write in the SQL Habit course will be available to you in History. So if you found a nice hack or learned something new – make sure to drop a comment in your query so you can retrieve it later. 🚀

Anatoli Makarevich, author of SQL Habit About SQL Habit

Hi, it’s Anatoli, the author of SQL Habit. 👋

SQL Habit is a course (or, as some of the students say, “business simulator”). It’s based on a story of a fictional startup called Bindle. You’ll play a role of their Data Analyst 📊 and solve real-life challenges from Business, Marketing, and Product Management.

SQL Habit course is made of bite-sized lessons (you’re looking at one atm) and exercises. They always have a real-life setting and detailed explanations. You can immediately apply everything you’ve learned at work. 🚀

“well worth the money”

Fluent in SQL in a month

Master Data Analysis with SQL with real life examples from Product Management, Marketing, Finance and more.
-- Type your query here, for example this one -- lists all records from users table: SELECT * FROM users
Loading chart... ⏳