All language subtitles for 5. Left Join

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French Download
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 0 1 00:00:02,370 --> 00:00:09,270 When we discussed inner join, we found out that only the intersection values are being returned back 1 2 00:00:09,600 --> 00:00:10,310 by the query. 2 3 00:00:12,150 --> 00:00:18,720 So basically inner join meant, finding out those values which are present in both the tables, Now suppose we 3 4 00:00:18,720 --> 00:00:24,630 want that table A stays with us all values from table a are there. 4 5 00:00:25,020 --> 00:00:30,930 And whenever there is some value in table B, It comes against that table A value, if it is 5 6 00:00:30,930 --> 00:00:32,880 not available, we will get the null value. 6 7 00:00:33,660 --> 00:00:34,980 If that is a requirement. 7 8 00:00:35,580 --> 00:00:42,290 left join is used. So left join will return all values in the left table even if there are no matches in the right 8 9 00:00:42,300 --> 00:00:42,630 table. 9 10 00:00:43,500 --> 00:00:44,760 The syntax for this is. 10 11 00:00:46,360 --> 00:00:46,870 Select. 11 12 00:00:47,930 --> 00:00:56,190 Column from table one or table two, from table one left join table 2 so this is similar to inner join. only instead 12 13 00:00:56,190 --> 00:00:57,810 of inner we are writing left join. 13 14 00:00:59,100 --> 00:01:03,430 On then you give the field that you want to be common in both the tables 14 15 00:01:03,960 --> 00:01:11,370 So what this will do is whole of the table A will be taken out and all the column values of table B 15 16 00:01:11,370 --> 00:01:18,660 against table A will be plotted if there is any value in table A, which is not in table B will 16 17 00:01:18,660 --> 00:01:21,510 get a null value for that particular column. 17 18 00:01:23,630 --> 00:01:29,960 So, for example, we had the sales table, Suppose against the sales table, we want to plot the customer 18 19 00:01:29,960 --> 00:01:30,620 information. 19 20 00:01:31,190 --> 00:01:37,550 When we did the inner join, some of the sales table values were dropped because they were not present 20 21 00:01:37,550 --> 00:01:38,510 in the customer table. 21 22 00:01:39,550 --> 00:01:46,450 Now, if we want that none of the sales table values are dropped, all the values remain there and against 22 23 00:01:46,570 --> 00:01:49,990 whichever there is customer value available, it should be plotted. 23 24 00:01:49,990 --> 00:01:55,910 And whichever there is no customer information available, it should be it should remain as null, there 24 25 00:01:55,960 --> 00:01:58,300 we will use left join as such, will. 25 26 00:01:58,300 --> 00:02:02,290 write select all the column names, some from the sales 26 27 00:02:02,290 --> 00:02:05,950 table, some from the customer table, from the sales table. 27 28 00:02:05,950 --> 00:02:08,270 That will be table one for which we want all 28 29 00:02:08,310 --> 00:02:11,320 the rows. Then left join with the customer table. 29 30 00:02:12,470 --> 00:02:16,910 On the customer id which is a common field, Order by customer id 30 31 00:02:17,420 --> 00:02:18,970 So let's go and write this query. 31 32 00:02:21,110 --> 00:02:27,840 So for convenience, I have written down the customer IDs which are present in the customer table and 32 33 00:02:27,840 --> 00:02:32,620 not present in the sales table, which are present in sales table not present in customer table and which are 33 34 00:02:32,630 --> 00:02:33,350 present in both. 34 35 00:02:34,010 --> 00:02:39,170 So that after we have written this query and we see the result, we can check finally, which is available 35 36 00:02:39,170 --> 00:02:40,570 in the final table and which is not. 36 37 00:02:40,700 --> 00:02:42,290 So let's start writing select. 37 38 00:02:46,580 --> 00:02:47,660 The order line. 38 39 00:02:50,490 --> 00:02:51,480 The product id. 39 40 00:02:57,950 --> 00:02:58,930 The customer id 40 41 00:03:01,690 --> 00:03:05,410 and the sales value. 41 42 00:03:07,570 --> 00:03:09,880 From the customer table, we will require. 42 43 00:03:11,610 --> 00:03:13,980 Customer name and customer age. 43 44 00:03:25,250 --> 00:03:42,410 From the table sales 2015 as a and, left join with customer table as b so this is customer 44 45 00:03:42,530 --> 00:03:43,370 2060. 45 46 00:03:47,370 --> 00:03:48,060 As b. 46 47 00:03:50,360 --> 00:03:50,870 On. 47 48 00:03:52,190 --> 00:03:56,930 Customer id a.customer id is equal to 48 49 00:03:59,870 --> 00:04:01,630 b.customer id 49 50 00:04:07,160 --> 00:04:10,390 ordered by customer id 50 51 00:04:15,710 --> 00:04:23,660 to if you scroll up, you can see that it is exactly same as the one written for inner join. Just as 51 52 00:04:23,660 --> 00:04:26,650 the join is now left instead of inner. 52 53 00:04:28,790 --> 00:04:31,400 Let's select this query and run it. 53 54 00:04:36,720 --> 00:04:39,300 So you can see this, these are the values that we got. 54 55 00:04:41,670 --> 00:04:51,240 So from the comment, you can check AA-10315 which is not present in the customer table, 55 56 00:04:52,020 --> 00:04:59,070 is present in our result set, what this means is since we took left join on the sales table, all the 56 57 00:04:59,070 --> 00:05:01,290 sales level values are available in this table. 57 58 00:05:01,920 --> 00:05:04,920 So AA-10315 is part of sales table 58 59 00:05:05,200 --> 00:05:06,810 So it is part of the Result Set. 59 60 00:05:07,440 --> 00:05:12,710 Since the customer name and age values are not available for this customer Id in the customer table, 60 61 00:05:13,500 --> 00:05:14,610 those are null. 61 62 00:05:16,690 --> 00:05:25,960 The AA-10375 customer is available in both the tables, so that value is present in the ResultSet 62 63 00:05:25,960 --> 00:05:35,020 along with the customer name and customer age, the AA-10480 is not available in this 63 64 00:05:35,020 --> 00:05:37,970 result set, since this was not part of the sales table. 64 65 00:05:38,650 --> 00:05:45,610 So basically in the left join, all values of table 1 are available and only the intersection values of table 65 66 00:05:45,610 --> 00:05:46,570 two are available. 66 67 00:05:47,840 --> 00:05:53,560 For the rows of table one, which are not available in table two, null values will be assigned in the result set. 67 68 00:05:54,620 --> 00:06:04,250 So this is left join. One thing to notice here since our sales table had multiple values with the same customer id 68 69 00:06:04,250 --> 00:06:05,020 you can see there are 69 70 00:06:05,900 --> 00:06:10,090 So for this particular customer, there are four values four rows coming. 70 71 00:06:10,550 --> 00:06:17,180 And against all these four rows, the same customer name and age is coming since our customer table 71 72 00:06:17,180 --> 00:06:19,250 has customer id as the primary key. 72 73 00:06:21,600 --> 00:06:28,740 If in the customer table, which is the table 2, so by chance in customer table, you have multiple values for 73 74 00:06:28,740 --> 00:06:37,890 same customer id you'll be having multiple rows for each transaction of the sales table for each 74 75 00:06:37,950 --> 00:06:38,650 row of the sales table 75 76 00:06:39,600 --> 00:06:45,570 What I mean is so, for example, for this particular customer id 10375 76 77 00:06:45,780 --> 00:06:47,880 We have two customers, Alan and John. 77 78 00:06:49,790 --> 00:06:56,360 When we take left join, for this particular row, there'll be two rows in the ResultSet, one will have 78 79 00:06:56,720 --> 00:07:00,320 Allen customer name and the other will have John as a customer name. 79 80 00:07:00,920 --> 00:07:08,190 Similarly for the other three rows also, it will having two per row. Overall for this particular customer, you 80 81 00:07:08,210 --> 00:07:10,360 would be having four rows in the ResultSet. 81 82 00:07:11,090 --> 00:07:13,610 This may not be the desired result set for you. 82 83 00:07:14,230 --> 00:07:19,070 So keep in mind, while using the left, join the matching key of the table. 83 84 00:07:19,070 --> 00:07:24,390 Two should either be a primary key or should have the unique constraint. 84 85 00:07:24,620 --> 00:07:30,170 This will give you the desired result in the next video we'll be discussing about the right joint. 8641

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.