Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
SQL Left & Right Join | SQL Joining Tables
Data Manipulation using SQL
course content

Зміст курсу

Data Manipulation using SQL

Data Manipulation using SQL

1. Database and Nested Queries
2. SQL Joining Tables
3. SQL Tasks

SQL Left & Right Join

LEFT JOIN returns all records from the left table and matching records from the right table. For records with no matching, it completes the fields with NULL. For example, let's select all albums joined with songs ids with LEFT JOIN:

123
SELECT albums.title, songs.id FROM albums LEFT JOIN songs ON songs.album_id = albums.id
copy

On the diagram for this query, we can see that not all albums have songs in a table, so absent fields are autocompleted with NULL. Similarly, we can see in the result query: some albums have empty id's for the songs, because there are no songs for these albums.

Завдання

Do the joining for tables albums and songs using INNER JOIN, RIGHT JOIN, FULL JOIN, and check the difference. Then, find the number of songs for each album (even if there are no songs in it). Think about which JOIN you can use here. Order everything by albums title.

Завдання

Do the joining for tables albums and songs using INNER JOIN, RIGHT JOIN, FULL JOIN, and check the difference. Then, find the number of songs for each album (even if there are no songs in it). Think about which JOIN you can use here. Order everything by albums title.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 2. Розділ 3
toggle bottom row

SQL Left & Right Join

LEFT JOIN returns all records from the left table and matching records from the right table. For records with no matching, it completes the fields with NULL. For example, let's select all albums joined with songs ids with LEFT JOIN:

123
SELECT albums.title, songs.id FROM albums LEFT JOIN songs ON songs.album_id = albums.id
copy

On the diagram for this query, we can see that not all albums have songs in a table, so absent fields are autocompleted with NULL. Similarly, we can see in the result query: some albums have empty id's for the songs, because there are no songs for these albums.

Завдання

Do the joining for tables albums and songs using INNER JOIN, RIGHT JOIN, FULL JOIN, and check the difference. Then, find the number of songs for each album (even if there are no songs in it). Think about which JOIN you can use here. Order everything by albums title.

Завдання

Do the joining for tables albums and songs using INNER JOIN, RIGHT JOIN, FULL JOIN, and check the difference. Then, find the number of songs for each album (even if there are no songs in it). Think about which JOIN you can use here. Order everything by albums title.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 2. Розділ 3
toggle bottom row

SQL Left & Right Join

LEFT JOIN returns all records from the left table and matching records from the right table. For records with no matching, it completes the fields with NULL. For example, let's select all albums joined with songs ids with LEFT JOIN:

123
SELECT albums.title, songs.id FROM albums LEFT JOIN songs ON songs.album_id = albums.id
copy

On the diagram for this query, we can see that not all albums have songs in a table, so absent fields are autocompleted with NULL. Similarly, we can see in the result query: some albums have empty id's for the songs, because there are no songs for these albums.

Завдання

Do the joining for tables albums and songs using INNER JOIN, RIGHT JOIN, FULL JOIN, and check the difference. Then, find the number of songs for each album (even if there are no songs in it). Think about which JOIN you can use here. Order everything by albums title.

Завдання

Do the joining for tables albums and songs using INNER JOIN, RIGHT JOIN, FULL JOIN, and check the difference. Then, find the number of songs for each album (even if there are no songs in it). Think about which JOIN you can use here. Order everything by albums title.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

LEFT JOIN returns all records from the left table and matching records from the right table. For records with no matching, it completes the fields with NULL. For example, let's select all albums joined with songs ids with LEFT JOIN:

123
SELECT albums.title, songs.id FROM albums LEFT JOIN songs ON songs.album_id = albums.id
copy

On the diagram for this query, we can see that not all albums have songs in a table, so absent fields are autocompleted with NULL. Similarly, we can see in the result query: some albums have empty id's for the songs, because there are no songs for these albums.

Завдання

Do the joining for tables albums and songs using INNER JOIN, RIGHT JOIN, FULL JOIN, and check the difference. Then, find the number of songs for each album (even if there are no songs in it). Think about which JOIN you can use here. Order everything by albums title.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 2. Розділ 3
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt