Previously, we learned that
SELECT is used every time you want to query data from a database and
* means all columns.
Suppose we are only interested in two of the columns. We can select individual columns by their names (separated by a comma):
SELECT column1, column2 FROM table_name;
To make it easier to read, we moved
FROM to another line.
Line breaks don’t mean anything specific in SQL. We could write this entire query in one line, and it would run just fine.
Let’s only select the
genre columns of the table.
In the code editor, type the following:
SELECT name, genre FROM movies;
Now we want to include a third column.
Edit your query so that it returns the
year columns of the table.