Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:07,936 --> 00:00:10,496
So now we will be starting with the quering commands
1
2
00:00:11,264 --> 00:00:15,104
We started with query commands when we discussed select and where statement
2
3
00:00:15,616 --> 00:00:19,456
If you remember, we retrieved data using the select statement
3
4
00:00:19,712 --> 00:00:21,760
From a particular table and then we
4
5
00:00:22,016 --> 00:00:24,832
Specified conditions using the where statement
5
6
00:00:26,368 --> 00:00:28,416
Also we discussed the OR AND
6
7
00:00:28,928 --> 00:00:29,952
Logical operators
7
8
00:00:30,208 --> 00:00:34,048
Which helps specify multiple conditions on the where statement
8
9
00:00:35,072 --> 00:00:37,376
Now we will be discussing the 'in' condition
9
10
00:00:37,632 --> 00:00:40,448
In condition is used with the where statement
10
11
00:00:40,704 --> 00:00:41,984
Just as the OR command
11
12
00:00:42,240 --> 00:00:43,520
Only difference is
12
13
00:00:43,776 --> 00:00:48,128
If you have multiple values and you want to specify a lot of values
13
14
00:00:48,640 --> 00:00:51,456
You will have to specify or condition every time
14
15
00:00:51,712 --> 00:00:55,808
If you have 50 values you have to write or condition 50 times
15
16
00:00:56,320 --> 00:00:57,344
But with in
16
17
00:00:57,600 --> 00:01:01,696
You can just try it in one time and you can specify all the 50 values
17
18
00:01:01,952 --> 00:01:02,976
In a single block
18
19
00:01:04,000 --> 00:01:05,792
So this is the syntax of in command
19
20
00:01:06,816 --> 00:01:07,584
You select
20
21
00:01:07,840 --> 00:01:10,656
The column names that you want from the table name
21
22
00:01:11,168 --> 00:01:12,960
And then you write the where condition
22
23
00:01:13,728 --> 00:01:17,824
And after that you specify the in command with all the values
23
24
00:01:18,080 --> 00:01:19,616
Specified in one single block
24
25
00:01:20,128 --> 00:01:21,664
So, this column name
25
26
00:01:21,920 --> 00:01:23,968
That you specified with the where condition
26
27
00:01:24,480 --> 00:01:28,832
This column can only have this value in the retrieved data set
27
28
00:01:29,600 --> 00:01:31,648
So, let us look at some of the examples
28
29
00:01:32,928 --> 00:01:36,768
For example in our customer table if I want to see
29
30
00:01:37,280 --> 00:01:39,328
Which customers belong to the
30
31
00:01:39,840 --> 00:01:42,144
City Philadelphia or Seattle
31
32
00:01:43,424 --> 00:01:44,704
There are two ways to do that
32
33
00:01:45,472 --> 00:01:47,264
One is to use the in statement
33
34
00:01:47,776 --> 00:01:52,640
Where I'll write in and then write the two values Philadelphia and Seattle
34
35
00:01:53,664 --> 00:01:54,944
The same thing I can
35
36
00:01:55,200 --> 00:02:01,344
Do with the OR statement where I use where city is equal to Philadelphia Or city is equal to Seattle
36
37
00:02:01,856 --> 00:02:03,648
You can imagine if I had
37
38
00:02:03,904 --> 00:02:05,440
15 or 20 cities
38
39
00:02:05,952 --> 00:02:09,536
I would have to write or statement 15 20 times
39
40
00:02:10,048 --> 00:02:13,632
Whereas with in, I just put a comma and write the city name
40
41
00:02:15,168 --> 00:02:19,008
Let us go and write this command in pg admin
41
42
00:02:19,776 --> 00:02:20,544
So now
42
43
00:02:21,312 --> 00:02:22,336
I will write the
43
44
00:02:22,592 --> 00:02:25,920
In command, select star
44
45
00:02:27,200 --> 00:02:30,016
From customer
45
46
00:02:30,272 --> 00:02:32,064
Where
46
47
00:02:35,136 --> 00:02:36,160
City
47
48
00:02:40,256 --> 00:02:42,816
First is Philadelphia
48
49
00:02:45,376 --> 00:02:47,168
And second one is Seattle
49
50
00:02:56,128 --> 00:02:57,920
If you run this command
50
51
00:02:59,456 --> 00:03:01,248
So you can see
51
52
00:03:02,016 --> 00:03:03,040
In the city column
52
53
00:03:03,552 --> 00:03:04,064
Only
53
54
00:03:04,320 --> 00:03:07,136
Seattle and Philadelphia are present
54
55
00:03:07,392 --> 00:03:09,696
All the other cities have been filtered out
55
56
00:03:11,744 --> 00:03:17,888
We could have done the same thing using the or statement
56
57
00:03:18,144 --> 00:03:24,288
Let us try this with the or statement
57
58
00:03:24,800 --> 00:03:30,944
Select star from customer where
58
59
00:03:31,200 --> 00:03:37,344
City is equal to Philadelphia
59
60
00:03:37,600 --> 00:03:43,744
Or
60
61
00:03:44,000 --> 00:03:50,144
City equal to Seattle
61
62
00:03:56,800 --> 00:03:59,104
You run this, you will get the same result
62
63
00:04:02,688 --> 00:04:05,504
So IN is basically a replacement for multiple or
63
64
00:04:06,272 --> 00:04:06,784
But
64
65
00:04:07,552 --> 00:04:10,880
In the later part of this course when will learn about sub queries
65
66
00:04:11,136 --> 00:04:13,952
You find that in place a very important role
66
67
00:04:14,208 --> 00:04:17,791
In writing Complex queries in a short and simple manner
67
68
00:04:19,071 --> 00:04:19,583
In the next
68
69
00:04:19,839 --> 00:04:21,887
Video we will learn about how to use the Between statement
5414
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.