From the course: MySQL Essential Training (2019)

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Joining queries across tables

Joining queries across tables - MySQL Tutorial

From the course: MySQL Essential Training (2019)

Joining queries across tables

- [Instructor] The ability to combine results from related rows in different tables is an important part of using a relational database system. In MySQL, this is accomplished with the JOIN clause. For this lesson, we'll use the Album database, here in MySQL Workbench, I'm connected with my Admin Connection and I will use album and execute. Now, let's start by looking at a simple example. If I SELECT * FROM track; and SELECT * FROM album; if I execute both of these statements, you see I get two tabs, got the album here and the track here. So, this is all the tracks and all the albums, and you notice that the album_id references the ID column in the Album table. So, here in the Track table, that album_id column is a foreign key, because it's actually the primary key in the Album table. So, if I want to get a result that joins these two tables and that will give me the tracks in an album with all of the attendant information, I can do that with a joined query. So, I'm going to come out…

Contents