MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Introduction to SQL Server

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

-- 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 dan Jalankan Kode