1 00:00:00,510 --> 00:00:02,160 I'm back with a very quick addition. 2 00:00:02,160 --> 00:00:07,560 This is a frequently asked question that I get pretty often, which is, is there really a big difference 3 00:00:07,560 --> 00:00:09,240 between right and left joints? 4 00:00:09,780 --> 00:00:14,310 If we just change the order of what we're joining and the answer is no, they're actually the same. 5 00:00:14,640 --> 00:00:22,320 So if we do a left join where this is customers A and then on the right we have orders that's identical 6 00:00:22,500 --> 00:00:24,150 to doing a right join. 7 00:00:24,420 --> 00:00:32,549 If instead we put customers over here and we put orders under a so think of it as just flipping this. 8 00:00:32,880 --> 00:00:34,200 There's no difference. 9 00:00:34,590 --> 00:00:36,230 So let me show you an example. 10 00:00:36,240 --> 00:00:41,760 If we go and we go grab our simple left, join from way back here. 11 00:00:42,750 --> 00:00:48,780 This one right here are simplest left join and I will paste it down here just so you have it to see 12 00:00:50,220 --> 00:00:51,630 and let's paste it in as well. 13 00:00:51,850 --> 00:00:52,150 Okay. 14 00:00:52,230 --> 00:00:54,270 First of all, there's a lot to look at, right? 15 00:00:55,020 --> 00:01:01,800 But what's most important is that we have on the left customers information first, and then on the 16 00:01:01,800 --> 00:01:05,040 right we have our order information right. 17 00:01:05,190 --> 00:01:08,310 And then we have nulls where we don't have a matching order. 18 00:01:09,570 --> 00:01:13,680 So what happens if we try and do the same thing? 19 00:01:13,680 --> 00:01:24,000 But instead of doing customers first, we do orders and we do a right join customers on customers ID 20 00:01:24,000 --> 00:01:26,520 equals orders dot customer ID. 21 00:01:28,770 --> 00:01:30,120 So if we do this. 22 00:01:32,450 --> 00:01:33,620 Look at what we get here. 23 00:01:34,160 --> 00:01:36,790 So we have the exact same data. 24 00:01:36,800 --> 00:01:39,080 One, two, three, four, five rows. 25 00:01:39,740 --> 00:01:41,390 One, two, three, four, five. 26 00:01:41,630 --> 00:01:45,170 But the order that they're printed is different, right? 27 00:01:45,380 --> 00:01:50,330 So we have on the left side now we have our orders, information. 28 00:01:51,260 --> 00:01:54,740 And then on the right, we have our customers information. 29 00:01:55,370 --> 00:01:58,550 But the actual data that's displayed is the same. 30 00:01:58,550 --> 00:01:59,990 Yes, the order changes. 31 00:02:00,500 --> 00:02:02,600 But that's trivial. 32 00:02:02,600 --> 00:02:03,620 That doesn't matter. 33 00:02:03,920 --> 00:02:06,740 So in effect, these are equivalent. 34 00:02:06,740 --> 00:02:13,160 And in fact, some like some environments that I've come across, some developing environments won't 35 00:02:13,160 --> 00:02:14,630 even support a right join. 36 00:02:14,630 --> 00:02:18,920 And they just want you to do a left join and switch the order. 37 00:02:19,940 --> 00:02:26,240 So to actually to sum up one more time, let's say I did the same thing here with orders and customers, 38 00:02:26,450 --> 00:02:27,770 but I did a left join. 39 00:02:28,790 --> 00:02:29,870 What would happen now? 40 00:02:30,560 --> 00:02:33,470 What's a left join with orders first and then customers. 41 00:02:34,190 --> 00:02:44,120 And the answer is it's the same as doing a right join, except if we start with customers and then orders. 42 00:02:46,280 --> 00:02:48,920 And unfortunately, we don't really have anything to see. 43 00:02:48,920 --> 00:02:53,660 Right, because our data doesn't have any discrepancies on the order side. 44 00:02:53,660 --> 00:02:57,620 This is what the entire last video is about, which I will not retread here. 45 00:02:57,620 --> 00:03:01,580 But my point is that they look the same and they look just like an inner join as well. 46 00:03:01,670 --> 00:03:07,370 But when we have something different, like with our left join for customers and orders, you can see 47 00:03:07,370 --> 00:03:09,080 that the data is actually the same.