Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:00,512 --> 00:00:03,840
In the last video, we learned how to use the in statement
1
2
00:00:05,120 --> 00:00:07,936
Now let us learn how to use the between condition
2
3
00:00:09,472 --> 00:00:13,824
Between condition is used to retrieve values within a particular range
3
4
00:00:15,104 --> 00:00:19,456
So while using between we'll need to specify a lower value
4
5
00:00:19,968 --> 00:00:20,480
And
5
6
00:00:20,736 --> 00:00:21,760
Upper value
6
7
00:00:22,016 --> 00:00:28,160
Between which the condition will be giving us the values back. The Syntax to use the between command is
7
8
00:00:28,416 --> 00:00:29,184
Select
8
9
00:00:29,440 --> 00:00:30,464
Column names
9
10
00:00:30,720 --> 00:00:31,744
From table names
10
11
00:00:32,256 --> 00:00:32,768
Where
11
12
00:00:33,024 --> 00:00:34,304
A Particular column
12
13
00:00:34,560 --> 00:00:39,680
Value is between a lower value and a higher value
13
14
00:00:40,192 --> 00:00:42,240
Let us look at an example
14
15
00:00:44,800 --> 00:00:47,360
Suppose we want to get all the customers
15
16
00:00:48,384 --> 00:00:50,944
Whose age is between 20 and 30
16
17
00:00:52,480 --> 00:00:54,784
This can be done using the between condition
17
18
00:00:56,064 --> 00:00:59,136
Select everything from the customer table where
18
19
00:00:59,648 --> 00:01:00,928
Age is between
19
20
00:01:01,184 --> 00:01:02,464
20 and 30
20
21
00:01:03,232 --> 00:01:06,048
Latest go and write this in the PG admin interface
21
22
00:01:09,376 --> 00:01:10,400
Select
22
23
00:01:10,656 --> 00:01:12,960
Star from customer
23
24
00:01:16,800 --> 00:01:18,592
Where
24
25
00:01:19,616 --> 00:01:20,384
Age
25
26
00:01:20,640 --> 00:01:22,944
Between
26
27
00:01:24,224 --> 00:01:25,248
Lower value
27
28
00:01:25,760 --> 00:01:29,856
And upper value
28
29
00:01:32,160 --> 00:01:33,696
Run this command
29
30
00:01:34,720 --> 00:01:35,744
You can see
30
31
00:01:36,256 --> 00:01:40,352
Only customers who have age between 20 and 30
31
32
00:01:42,144 --> 00:01:43,424
Are Remaining
32
33
00:01:43,680 --> 00:01:45,472
Important thing to note here is
33
34
00:01:45,728 --> 00:01:48,032
Both the value 20 and 30
34
35
00:01:49,312 --> 00:01:50,336
Are included
35
36
00:01:50,592 --> 00:01:52,896
Customer with the age of 20 years
36
37
00:01:53,152 --> 00:01:55,712
Will be part of this retrieve data set
37
38
00:01:57,504 --> 00:01:59,040
This same result can be
38
39
00:01:59,808 --> 00:02:05,952
Retrieved using the and statement, So if I write select star from
39
40
00:02:06,208 --> 00:02:09,792
Customer where
40
41
00:02:10,048 --> 00:02:15,936
Age greater than equal to 20
41
42
00:02:16,448 --> 00:02:21,824
And age less than equal to
42
43
00:02:22,080 --> 00:02:23,360
30
43
44
00:02:26,944 --> 00:02:30,528
Running this command will give us back the same result
44
45
00:02:32,576 --> 00:02:33,088
Now
45
46
00:02:33,600 --> 00:02:39,744
The between statement can also be clubbed with the not statement. Let us look at the syntax of how
46
47
00:02:40,000 --> 00:02:42,304
We can club not and between statement
47
48
00:02:43,072 --> 00:02:45,376
We'll write select star from customer
48
49
00:02:45,632 --> 00:02:48,960
Where age not between 20 and 30
49
50
00:02:49,984 --> 00:02:52,032
As you can guess what this will do it
50
51
00:02:52,288 --> 00:02:56,128
We will get back all the customers whose age is not between
51
52
00:02:56,896 --> 00:03:00,224
20 years and 30 years. Let's go and run this query
52
53
00:03:05,600 --> 00:03:10,976
Customer table where
53
54
00:03:13,280 --> 00:03:16,864
Age not between
54
55
00:03:17,376 --> 00:03:20,960
20 and 30
55
56
00:03:22,496 --> 00:03:24,288
Run this command
56
57
00:03:25,312 --> 00:03:26,080
You can see
57
58
00:03:26,848 --> 00:03:27,872
All the customers
58
59
00:03:28,384 --> 00:03:30,688
That we have in our retrieve data set
59
60
00:03:31,456 --> 00:03:32,736
Do not belong to the
60
61
00:03:33,248 --> 00:03:35,296
Age category of 20 to 30
61
62
00:03:37,344 --> 00:03:40,416
Also another thing you can note is
62
63
00:03:40,672 --> 00:03:42,720
Between statement can be used
63
64
00:03:42,976 --> 00:03:44,512
With dates also
64
65
00:03:45,024 --> 00:03:46,816
If you want to find out
65
66
00:03:47,328 --> 00:03:48,608
All the data.
66
67
00:03:48,864 --> 00:03:49,888
Which belong
67
68
00:03:50,144 --> 00:03:52,192
To a particular time range
68
69
00:03:52,448 --> 00:03:56,288
For example, if you want to find out all the orders
69
70
00:03:56,544 --> 00:03:57,568
That u shipped
70
71
00:03:57,824 --> 00:04:00,128
Between a particular time range say
71
72
00:04:00,384 --> 00:04:02,944
Between 1st April 2015
72
73
00:04:03,200 --> 00:04:05,504
To 1st April 2016
73
74
00:04:06,016 --> 00:04:09,856
You can find that using the between statement such as this
74
75
00:04:10,112 --> 00:04:12,160
Select star from sales
75
76
00:04:12,416 --> 00:04:13,184
Ship Date
76
77
00:04:13,440 --> 00:04:14,464
Between
77
78
00:04:15,488 --> 00:04:19,839
This is the lower value of the date 1st April 2015
78
79
00:04:20,095 --> 00:04:23,167
And that is the upper value 1st April 2016
79
80
00:04:23,423 --> 00:04:25,215
Note the format of date
80
81
00:04:25,471 --> 00:04:27,263
It is YYYY
81
82
00:04:27,519 --> 00:04:33,663
MM DD, first the year then the month then the date so let's go and write this query
82
83
00:04:36,991 --> 00:04:38,783
From
83
84
00:04:39,295 --> 00:04:41,343
This is the sales table
84
85
00:04:43,135 --> 00:04:48,767
Where ship date between
85
86
00:04:53,375 --> 00:04:59,519
2015 04 01
86
87
00:05:01,567 --> 00:05:02,591
And
87
88
00:05:05,663 --> 00:05:10,783
Remember to put single quotation mark around the date values and
88
89
00:05:11,295 --> 00:05:16,927
Single code 2016 04 01
89
90
00:05:18,207 --> 00:05:20,255
And select this command and run it
90
91
00:05:23,583 --> 00:05:24,607
You can see
91
92
00:05:25,119 --> 00:05:26,399
The ship date
92
93
00:05:27,423 --> 00:05:31,007
Column has only the values which belong to this
93
94
00:05:31,263 --> 00:05:32,031
Date range
94
95
00:05:33,823 --> 00:05:36,127
That is how we use the between statement
6703
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.