Get startedGet started for free

RIGHT JOIN

Let's now try some RIGHT joins. A RIGHT join will return all rows from the right hand table, plus any matches from the left hand side table.

In addition to performing a RIGHT join, you'll also learn how to avoid problems when different tables have the same column names, by fully qualifying the column in your select statement. Remember, we do this by prefixing the column name with the table name.

For this exercise, we'll return to the Chinook database from earlier in the chapter.

This exercise is part of the course

Introduction to SQL Server

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

-- SELECT the fully qualified album_id column from the album table
SELECT 
  ___,
  title,
  album.artist_id,
  -- SELECT the fully qualified name column from the artist table
  ___ as artist
FROM album
-- Perform a join to return only rows that match from both tables
INNER JOIN artist ON album.artist_id = artist.artist_id
WHERE album.album_id IN (213,214)
Edit and Run Code