Instruction
Fine, let's start with something easy. But before we do, we should get to know the tables we will be operating on.
We'll use two simple tables which come from an art gallery. On the right side of the screen, there is a button named – click on it to study the structure of the tables.
The table artist includes:
- the identifier (column
id). - first and last name (columns
first_name,last_name). - the exact dates when the artist was born and when they died (columns
born,died). - and their nationality (column
nationality).
The table painting includes:
- the painting id (column
id). - the id of the artist (column
artist_id). - its title (column
title). - the year it was created (column
painted). - and the quality rating of the painting by some local experts (column
rating).
So, are you ready for your first exercise?
Exercise
For each painting created in 1800 or later, show its title and the year it was painted (column painted). Include paintings for which the creation date is unknown.
Stuck? Here's a hint!
To filter the paintings created after 1800, you should use a WHERE clause. Additionally, remember that to check whether a column is NULL you need to use an IS NULL statement.
Want to refresh your knowledge of SQL basics? Take a look at our SQL Queries course, Part 2: Selecting from one table.



