WEBVTT

00:07.640 --> 00:09.740
Okay, I will call you back again.

00:09.770 --> 00:14.600
So in this PostgreSQL lecture we are going to look at left join.

00:14.600 --> 00:20.000
So in the previous lecture we looked at join and we can see how we join these two tables.

00:20.000 --> 00:21.770
But there is one thing here.

00:21.770 --> 00:29.870
If you look at the table with join we have another strange table about four of these rows.

00:29.870 --> 00:38.000
And when we join these we have only three rows because we joined only students that have phones assigned

00:38.030 --> 00:38.660
to them.

00:38.660 --> 00:46.130
Now as a data analyst you may be asked, oh, and need you to present to me the data set of every student

00:46.130 --> 00:50.000
in this school who have bought phones and who doesn't have phones.

00:50.000 --> 00:53.990
And you'll be like, how can I be able to achieve this?

00:54.110 --> 00:57.920
So that is where the left join comes into play.

00:57.920 --> 01:05.730
So the join method, we actually or the join keyword, we only give you people who assigned phone to

01:05.760 --> 01:09.030
them or who assigned anything to them.

01:09.030 --> 01:14.940
But the left join will give you what students who have phone assigned to them, and students who do

01:14.940 --> 01:16.680
not have phone assigned to them.

01:16.680 --> 01:18.810
And now let's go ahead and do that.

01:18.810 --> 01:22.110
So this is just the same thing we would have just done.

01:22.110 --> 01:25.860
And I'm going to do it instead of me going over to do this.

01:25.890 --> 01:32.160
Let's go ahead and simply select whatever we have here so that you will know that all these are still

01:32.160 --> 01:33.720
the set already.

01:33.750 --> 01:36.930
And I'm going to select all from here.

01:36.930 --> 01:39.570
And I'm going to press that just down here.

01:39.570 --> 01:42.960
And I'm not going to put a semicolon at the end.

01:42.990 --> 01:44.400
Go ahead and hit enter.

01:44.430 --> 01:50.280
Now if I shoot one here and copy this join and copy this.

01:50.310 --> 01:53.970
If I press that day I'm going to replicate exactly this.

01:54.000 --> 01:58.890
But now I'll go ahead and add left and then press what I have.

01:58.890 --> 02:07.740
So I have left join phone on on a new table created student dot phone underscore ID equal to funded

02:07.740 --> 02:07.780
80.

02:07.780 --> 02:16.210
And if I hit this now, you can see that I have this new tool created and I have the razor line.

02:16.240 --> 02:17.140
Voila!

02:17.170 --> 02:21.400
Assigned under this, but without a phone.

02:22.060 --> 02:27.670
So you can see that we are able to get both students who we are, who have phone assigned to them,

02:27.670 --> 02:31.600
and students who don't know how phone assigned to them in left join.

02:31.600 --> 02:34.840
So the left join helps you to add everything together.

02:34.870 --> 02:40.360
But when you use the join keyword alone, you just get people have this assigned to them alone.

02:40.960 --> 02:45.970
So this is applicable when I go ahead to select a specified columns.

02:45.970 --> 02:52.780
If I go ahead and copy this and come over here and I go ahead and press this and hit enter a warhead

02:52.780 --> 02:55.660
and say from student I'm going to copy this.

02:55.720 --> 02:57.880
Remember that this is what we did in previous lecture.

02:57.880 --> 03:04.690
So I'm trying to replicate that so you can be able to follow on without getting uh distracted or confused.

03:04.690 --> 03:06.130
So I'll go ahead and copy this.

03:06.130 --> 03:10.690
And then over here I'll just go ahead and add the left and press this.

03:10.690 --> 03:15.040
Now hit enter and you can see that I have four rows.

03:15.040 --> 03:18.280
And in the previous lecture we have three rows.

03:18.310 --> 03:27.790
Now you can see guru has Motorola, Tokubei has image, George has and Song Wang Rosalind has been assigned

03:27.820 --> 03:28.810
to her.

03:29.350 --> 03:37.960
So that is the difference between, uh, the join method or the join Kuwait and the left join keyword.

03:37.990 --> 03:38.770
Now that is cool.

03:38.770 --> 03:42.580
So what if you are asked to get students who don't have anything assigned to them?

03:42.580 --> 03:43.960
How can you be able to do that?

03:43.960 --> 03:48.040
So that is very simple a while and say select uh.

03:50.530 --> 03:52.600
I want to select all.

03:52.600 --> 04:05.680
Then from the students table the algorithm is where class where uh the font ID because this is the font

04:06.940 --> 04:08.200
ID right.

04:08.200 --> 04:10.780
So we're using the font ID to actually check this.

04:10.780 --> 04:17.600
So we are the font underscore ID Is no.

04:17.630 --> 04:19.490
Put a semicolon at the end and hit enter.

04:19.490 --> 04:23.480
And you can see we have Rosa Len, uh, Mayweather.

04:23.480 --> 04:26.840
And no phone was assigned to her.

04:27.170 --> 04:27.530
All right.

04:27.560 --> 04:34.250
So this is how you can be able to check out the student who has no phone assigned to him or her.

04:34.250 --> 04:36.800
And, uh, you can be able to display that out.

04:36.800 --> 04:40.790
And this helps us to display every student that has phone assigned to him or her.

04:40.790 --> 04:43.250
And that is the power of the left join.

04:43.250 --> 04:48.230
So the right the join actually gives you only people who are all have phone assigned to them.

04:48.230 --> 04:53.900
What's the left join gives you everybody who have puts phone or no phone assigned to him or her, and

04:53.900 --> 04:58.760
you get the data set for your own purpose or whatever you want to do with it.

04:58.760 --> 05:00.140
So that is it for now.

05:00.140 --> 05:03.140
On left, join while I put it down, practice with it.

05:03.140 --> 05:06.620
And if you have any question, what had I use the question and answer section?

05:06.620 --> 05:09.080
And I'm going to get back to you as soon as possible.

05:09.110 --> 05:10.070
Thank you so much.

05:10.070 --> 05:12.890
And I'm going to see you in the next video lecture.
