Time
9 hours 41 minutes
Difficulty
Intermediate
CEU/CPE
10

Video Transcription

00:00
I welcome back to module to quick review. This is less than 2.3 the inner join,
00:06
and in this lesson, we're gonna go over the basics of dinner join. But to keep things a little interesting, we're going to use a self reference on one table to create an inner join.
00:16
And the table I'm interested in is this employees table, and the joint that I'm interested in involves this constraint. So if I click that, I'll see that it highlights the reports to field and the employee number field.
00:31
So without. I've seen this type relationship before, and I suspect that it's an employee to manager relationship, and this constraint requires that the reports to field be a really employee number.
00:44
So we can't, you know, employee number negative one probably doesn't exit exist, so we won't find that number in this. And these kind of constraints help protect database integrity because it's easy for a programmer or a front end user to make a mistake, type the wrong number and put in a reference to something that doesn't exist.
01:03
Constraints again. Help us avoid that.
01:06
But we're more focused on the inner join in this lesson So let's go ahead and get started.
01:11
So if we go to this script and take a look at a simple query I wrote,
01:18
we can see that I've joined
01:19
or that I'm selecting from the employees table. I've a liest it with an E. P for employees.
01:26
And then I'm joining
01:29
another reference to employees table. But I've alias this reference with man for manager,
01:34
and I'm joining E. P reports to
01:38
on man dot employee number. We could see that generates the results down here,
01:44
and I can run this again just to get the exact same results.
01:47
We can see that you know, Diane Murphy looks like she supervises two people Mary Patterson, three people.
01:55
And then there's even more down below that
01:57
now. The key take away about the inner join is that it requires a valid reference in the joining columns to return data.
02:06
So
02:07
if, for example, this man dot employee number doesn't exist or set to know, we won't get a record back or any data back on that joint at all, we won't get any P back, even if any P employee exists
02:23
and the same is true for the reverse two if something exists on the man, but not on the E. P record again, we're not going to get anything back. And that is how the inner join works requires a reference on the joining columns on both tables.
02:38
With that said,
02:39
let's go ahead and let's go ahead and head over to the summary
02:44
and that brings us to the inner joins summary and just ah, review. The joining key requires representation on both tables. We can see that when we look at the Venn diagram for this as well, which comes from Wikipedia, Table A and table B. Both share the results set in the middle with shaded orange.
03:02
And that is the big take away about the inner joint Is that when you join on those columns, both tables have tohave
03:10
a result to return any data at all back, which is different from the left and right. Join which we will be going over in the next lessons. Hope to see you there. Thank you

Up Next

Intermediate SQL

This free course introduces the student to intermediate concepts found in the implementation and application of Structured Query Language (SQL) within professional business environments.

Instructed By

Instructor Profile Image
Kitt Parker
Instructor