Comments

A comment is a note for people; the database skips it. In SQL, a comment starts with two dashes, --, and goes on to the end of the line:

-- Games for the summer sale
SELECT title, price
FROM games; -- the price is in dollars

A longer note can span several lines between /* and */:

/* The shop's newsletter goes to every customer.
   It needs their names and emails. */
SELECT name, email
FROM customers;

Comments explain what a query is for, which isn't always clear from the query itself. They are also handy when you want a statement to stop running for a while, without deleting it: put -- in front of it. Programmers call that commenting out. To make the statement run again, delete the dashes.

A statement that spans several lines needs -- in front of each of its lines, or you put it all between /* and */.

Instructions

Above the first query, on the first line of the file, write a comment that says what the query shows, for example -- The titles of all games.

The reviews take up a lot of space in the result. Comment out the last query, so that it doesn't run but stays in the file.

Below it, add a query that shows only the stars of every review (the column stars).

stars
5
4
5
…

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

4/8