WEBVTT

00:00.090 --> 00:02.150
Okay I'm back with a very quick EDITION.

00:02.150 --> 00:07.560
This is a frequently asked question that I get pretty often which is is there really a big difference

00:07.560 --> 00:12.130
between right and left joins if we just change the order of what we're joining.

00:12.150 --> 00:14.650
And the answer is No they're actually the same.

00:14.790 --> 00:18.460
So if we do a left join where this is customers a.

00:18.930 --> 00:24.170
And then on the right we have orders that's identical to doing a RIGHT JOIN.

00:24.540 --> 00:29.950
If instead we put customers over here and we put orders under way.

00:30.180 --> 00:34.740
So think of it as just you know flipping this there's no difference.

00:34.740 --> 00:36.210
So let me show you an example.

00:36.360 --> 00:42.460
If we go and we go grab our simple left join from way back here.

00:42.800 --> 00:50.270
This one right here simpleness left join and I will paste it down here just you have it to see.

00:50.270 --> 00:51.610
And let's paste it in as well.

00:51.910 --> 00:52.180
OK.

00:52.200 --> 00:54.860
First of all there's a lot to look at right.

00:55.140 --> 01:02.190
But what's most important is that we have on the left customer's information first and then on the right

01:02.550 --> 01:05.110
we have our order information right.

01:05.370 --> 01:08.380
And then we have Knoll's where we don't have a matching order.

01:08.690 --> 01:09.300
OK.

01:09.720 --> 01:13.540
So what happens if we try and do the same thing.

01:13.800 --> 01:23.580
But instead of doing customers first we do orders and we do a right join customers on customers that

01:23.580 --> 01:26.920
ID equals orders customer ID.

01:27.510 --> 01:28.450
OK.

01:28.830 --> 01:33.870
So if we do this look at what we get here.

01:34.300 --> 01:36.860
So we have the exact same data.

01:36.930 --> 01:44.600
One two three four five rows one two three four five but the order that they're printed is different.

01:44.620 --> 01:45.540
Right.

01:45.580 --> 01:53.920
So we have on the left side now we have our orders information and then on the right we have our customers

01:53.920 --> 01:58.470
information but the actual data that's displayed is the same.

01:58.510 --> 02:02.620
Yes the order changes but that's know trivial.

02:02.620 --> 02:04.030
That doesn't matter.

02:04.030 --> 02:06.690
So in effect these are equivalent.

02:06.910 --> 02:13.390
And in fact some like some environments that I've come across some developing environments won't even

02:13.390 --> 02:19.290
support a right join and they just want to do a left join and switch the order.

02:20.080 --> 02:25.990
So to actually to sum up one more time let's say I did the same thing here with orders and customers

02:26.550 --> 02:28.870
but I did a left join.

02:28.870 --> 02:30.500
What would happen now.

02:30.640 --> 02:33.760
What's a left join with orders first and then customers.

02:34.390 --> 02:39.200
And the answer is it's the same as doing a right join.

02:39.520 --> 02:44.850
Except if we start with customers and then orders.

02:46.380 --> 02:52.720
And unfortunately we don't really have anything to see right because our data doesn't have any discrepancies

02:52.720 --> 02:53.650
on the order side.

02:53.650 --> 02:59.080
This was the entire last video was about which I will not retread here but my point is that they look

02:59.080 --> 03:04.060
the same and they look just like an inner join us well but when we have something different like with

03:04.210 --> 03:08.820
our left join for customers and orders you can see that the data is actually the same.
