Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:00,240 --> 00:00:08,340
Now, let us see the right join. Right join is similar to left join only that when we are doing the right join all rows
1
2
00:00:09,060 --> 00:00:12,300
of the table b will be kept in the result set
2
3
00:00:13,410 --> 00:00:20,670
Even if it is not present in the table A, wherever the table a vlaue is not present, will get null values.
3
4
00:00:20,970 --> 00:00:26,160
This syntex of right join is also same only instead of left join we will write right join.
4
5
00:00:27,200 --> 00:00:28,400
Let us look at the example.
5
6
00:00:29,850 --> 00:00:35,870
So last time when we did left join, we were finding out against each sales order.
6
7
00:00:35,970 --> 00:00:37,010
Who was the customer?
7
8
00:00:37,440 --> 00:00:43,280
Even if there were some records where we did not have customer names, this time we want to find out
8
9
00:00:43,740 --> 00:00:47,570
against all customer names if there is any sales value or not.
9
10
00:00:48,030 --> 00:00:51,920
This we will do by using the right join on the customer table.
10
11
00:00:51,930 --> 00:00:54,090
So customer table will be our table b again.
11
12
00:00:54,480 --> 00:00:56,390
But we will have all values of this.
12
13
00:00:56,400 --> 00:00:58,830
table b because will be doing the right join.
13
14
00:00:59,640 --> 00:01:04,920
So what happens here is we will select all the column that we want with the same as the earlier examples
14
15
00:01:05,700 --> 00:01:12,030
from sales table, which is our table a. Right join on table B, which is customer table.
15
16
00:01:12,360 --> 00:01:14,220
Since we want all values of customers.
16
17
00:01:15,390 --> 00:01:22,400
On the common field is customer id, and then we will order it by customer id, let's go and write this in the pgAdmin interface.
17
18
00:01:23,820 --> 00:01:28,550
So again, you can see 10315 is not present in customer table.
18
19
00:01:28,560 --> 00:01:31,690
Will this be President in the ResultSet? take a guess
19
20
00:01:32,690 --> 00:01:40,670
10375 is President in both tables, 10480 is not present in sales table, So guess
20
21
00:01:40,670 --> 00:01:43,740
which of these will be President in the ResultSet let us find out.
21
22
00:01:44,750 --> 00:01:46,910
So select.
22
23
00:01:49,540 --> 00:01:51,490
a.orderline
23
24
00:02:01,910 --> 00:02:05,120
a.product id
24
25
00:02:08,860 --> 00:02:10,150
a.customer id
25
26
00:02:16,630 --> 00:02:16,940
sales.
26
27
00:02:19,370 --> 00:02:21,920
next is b.customer name.
27
28
00:02:26,180 --> 00:02:27,770
and b dot
28
29
00:02:33,660 --> 00:02:40,340
Age from table a is our sales table
29
30
00:02:43,530 --> 00:02:48,120
2015 as a. Right join
30
31
00:02:51,480 --> 00:03:03,780
on customer table customer 2060 as b common field is customer id.
31
32
00:03:13,790 --> 00:03:15,450
And we will ordered it by
32
33
00:03:19,460 --> 00:03:20,420
customer id
33
34
00:03:27,260 --> 00:03:27,790
Run.
34
35
00:03:36,880 --> 00:03:42,540
So let's see which is present and which is not present, one zero three one five is not present.
35
36
00:03:43,850 --> 00:03:49,030
Why is it not present, because it is not present in the customer table and we have done a right join. So,
36
37
00:03:49,040 --> 00:03:51,890
all values of customer table should be present.
37
38
00:03:52,850 --> 00:03:55,510
If it is not present in customer table, it should not be there.
38
39
00:03:55,730 --> 00:03:58,940
So A10315 is not there.
39
40
00:04:00,420 --> 00:04:06,040
10375 is present in both tables it should be there. But can you find 10480
40
41
00:04:06,040 --> 00:04:06,300
?
41
42
00:04:07,170 --> 00:04:12,700
It is not present in the sales table, but it is present in the customer table, so it should be part of the result set
42
43
00:04:12,910 --> 00:04:16,260
Since Whiteaker, they join, but it is not here.
43
44
00:04:17,060 --> 00:04:17,750
Where is it?
44
45
00:04:19,240 --> 00:04:20,500
So let us go down.
45
46
00:04:22,170 --> 00:04:26,820
And see that there are some values where customer that is coming as.
46
47
00:04:28,110 --> 00:04:29,700
But it is part of the ResultSet.
47
48
00:04:30,740 --> 00:04:37,640
These are the values, these are the records of customer table, which are here because these were not
48
49
00:04:37,640 --> 00:04:42,270
present in the sales table and that is why it is giving a customer the idea of knowledge.
49
50
00:04:42,380 --> 00:04:50,600
Since we were taking the customer I a table where there was no such record to get these records, let
50
51
00:04:50,600 --> 00:04:52,110
us get the customer different.
51
52
00:04:52,110 --> 00:04:57,980
They will be so let us change it to be and now run this query.
52
53
00:05:05,620 --> 00:05:06,910
Now you can see.
53
54
00:05:08,350 --> 00:05:11,530
Here is your customer ready, a one zero four zero.
54
55
00:05:12,490 --> 00:05:16,100
You get the customer name and age because it is present in the customer table.
55
56
00:05:16,960 --> 00:05:24,070
We are not getting the order line productivity and the sales value because it is not traditional staple.
56
57
00:05:27,030 --> 00:05:31,390
And the second thing is this, customarily one zero three seven five.
57
58
00:05:33,090 --> 00:05:36,450
This was present only once in the customizable.
58
59
00:05:38,020 --> 00:05:44,740
So when I told you that it is taking out all the records of customer table, you may have thought that
59
60
00:05:44,740 --> 00:05:48,040
it will give only one record and the is all set for this customer ready.
60
61
00:05:48,610 --> 00:05:54,760
But that is not so since there were four different order values in the sales table for this particular
61
62
00:05:54,760 --> 00:05:55,100
customer.
62
63
00:05:55,660 --> 00:05:59,460
The ResultSet will have four different rules for this customer.
63
64
00:06:00,190 --> 00:06:07,450
This is the concept I was conveying in the last letter also that if you want single value in the customer
64
65
00:06:07,450 --> 00:06:14,010
table, you should ensure that the key that you're using should be primary or unique in the other table.
65
66
00:06:14,590 --> 00:06:21,820
So this customer adds, if it was a unique key in the sales table, there would have been only one rule.
66
67
00:06:22,390 --> 00:06:23,900
So this is how we use Ridvan.
67
68
00:06:24,700 --> 00:06:26,740
In the next lecture, we will look at the Autotuning.
6788
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.