Quiz
3. Task 2: Selecting rows from multiple tables

Instruction

Excellent work!

Now, let's see if you can still recall how to work with more than one table. Let's analyze the next situation:

Pet (Id, OwnerId, Name, Type, YearBorn)

Owner (Id, Name, YearBorn)

In this task, our small database collects information about pets and their owners in two separate tables.

Each pet has an ID, is assigned to a specific owner, has a name, is of a certain type (dog, cat, etc.) and was born in a specific year.

Each owner has an ID, a name and, again, was born in a specific year.

Exercise

Show all pets (show the columns Name, Type, and YearBorn) whose name begins with an 'M' together with their owners (the columns Name, YearBorn).

Rename the YearBorn column of the Pet table to PetYearBorn and the YearBorn column of the table Owner to OwnerYearBorn.

Stuck? Here's a hint!

Use the following template to help you build your query:

SELECT
  ...
FROM ...
INNER JOIN ...
  ON ...
WHERE ...;