Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:01,024 --> 00:00:03,072
Next is the substring function
1
2
00:00:03,584 --> 00:00:07,936
Substring function is used to extract a substring of a string
2
3
00:00:08,448 --> 00:00:13,056
So for example, if you have a long string and you want to take out a part of that string
3
4
00:00:13,312 --> 00:00:15,360
That is where substring will help you
4
5
00:00:16,896 --> 00:00:20,992
The syntax for substring is you write substring and within the parentheses
5
6
00:00:21,248 --> 00:00:23,296
You write the string first
6
7
00:00:23,808 --> 00:00:24,832
Then you mention
7
8
00:00:25,088 --> 00:00:30,208
From the starting position so you will give the starting position after writing the keyword from
8
9
00:00:31,488 --> 00:00:34,560
After that you can mention the length of characters
9
10
00:00:35,072 --> 00:00:37,120
That you want after the starting position
10
11
00:00:37,632 --> 00:00:39,680
So for this much length
11
12
00:00:42,240 --> 00:00:45,312
Let us look at an example to understand the substring function
12
13
00:00:48,384 --> 00:00:52,736
If you remember in the customer table customer id has two parts
13
14
00:00:53,760 --> 00:00:59,904
The first part is the two characters these two characters are the first characters of the customers name first name
14
15
00:01:00,160 --> 00:01:00,928
Last name
15
16
00:01:02,720 --> 00:01:05,024
After those two characters that is a hyphen
16
17
00:01:05,536 --> 00:01:11,168
And after that hyphen there are five numbers which may be randomly generated
17
18
00:01:11,680 --> 00:01:12,704
If you want to
18
19
00:01:12,960 --> 00:01:14,496
Segregate these two parts
19
20
00:01:15,264 --> 00:01:17,824
So, if you want to get the initials of the customer
20
21
00:01:18,336 --> 00:01:23,200
Separately into one column and if you want to get the unique identifying number
21
22
00:01:23,456 --> 00:01:24,480
Into another column
22
23
00:01:25,504 --> 00:01:27,296
You can do that using the substring
23
24
00:01:27,808 --> 00:01:33,952
with the first select statement I am writing customer ID customer name
24
25
00:01:34,208 --> 00:01:38,560
and I am getting the substring, the first two characters of the customer ID
25
26
00:01:39,072 --> 00:01:42,144
You can see the syntax here substring
26
27
00:01:42,400 --> 00:01:44,448
I will mention the column name
27
28
00:01:45,472 --> 00:01:48,032
For 2 I have not mentioned from
28
29
00:01:48,288 --> 00:01:48,800
Because
29
30
00:01:49,312 --> 00:01:49,824
From
30
31
00:01:50,080 --> 00:01:56,224
By default it will be the first character if I want to get it to some other position I have to mention the
31
32
00:01:56,480 --> 00:01:57,504
From keyword
32
33
00:01:58,016 --> 00:02:00,320
This column I have named as customer group
33
34
00:02:01,088 --> 00:02:04,160
From customer table where substring
34
35
00:02:04,416 --> 00:02:10,048
Customer ID for 2 is equal to AB so what this will give me is
35
36
00:02:10,304 --> 00:02:11,072
Only those
36
37
00:02:11,328 --> 00:02:16,192
Records with customer ID is starting with characters AB
37
38
00:02:16,704 --> 00:02:18,752
The 2nd select statement
38
39
00:02:19,264 --> 00:02:22,336
I am taking out the five randomly generated
39
40
00:02:22,592 --> 00:02:23,104
Digits
40
41
00:02:23,360 --> 00:02:24,128
To do that
41
42
00:02:24,896 --> 00:02:26,944
I have to start from the 4th position
42
43
00:02:27,456 --> 00:02:30,528
In the first two position is the these two characters
43
44
00:02:30,784 --> 00:02:32,576
The third position is taken by
44
45
00:02:32,832 --> 00:02:33,600
The hyphen
45
46
00:02:34,368 --> 00:02:36,672
So the number starts from 4th position
46
47
00:02:37,184 --> 00:02:38,464
and the number has
47
48
00:02:38,976 --> 00:02:40,768
Length of 5 characters
48
49
00:02:41,024 --> 00:02:42,304
So there are five different
49
50
00:02:43,072 --> 00:02:43,840
Numbers
50
51
00:02:44,352 --> 00:02:45,888
I'll take out this
51
52
00:02:46,144 --> 00:02:46,912
5
52
53
00:02:47,680 --> 00:02:49,216
Characters as a substring
53
54
00:02:50,496 --> 00:02:53,568
Let us go and write these two queries to get the two
54
55
00:02:54,080 --> 00:02:55,360
Parts of the customer ID
55
56
00:02:57,152 --> 00:03:03,296
So select customer ID customer name
56
57
00:03:05,088 --> 00:03:10,720
and Substring
57
58
00:03:11,488 --> 00:03:13,792
Mention the string
58
59
00:03:14,304 --> 00:03:17,376
Which will be the column name
59
60
00:03:17,888 --> 00:03:19,424
For two characters
60
61
00:03:19,680 --> 00:03:23,776
Name this column as customer group
61
62
00:03:25,568 --> 00:03:28,384
This all is coming from table
62
63
00:03:29,920 --> 00:03:30,688
Customer
63
64
00:03:32,224 --> 00:03:35,040
Where
64
65
00:03:36,064 --> 00:03:37,344
The first two characters
65
66
00:03:38,368 --> 00:03:44,512
are AB. so I will copy this substring down and this should be same as AB
66
67
00:03:45,024 --> 00:03:47,584
Let us select this query and run it
67
68
00:03:54,496 --> 00:03:57,312
You can see I have only those
68
69
00:03:57,824 --> 00:04:01,152
Customers where customer ID is starting with AB
69
70
00:04:03,712 --> 00:04:06,016
and the customer group column has that
70
71
00:04:06,784 --> 00:04:07,552
Substring
71
72
00:04:07,808 --> 00:04:10,624
The first two characters of the customer ID
72
73
00:04:11,136 --> 00:04:13,696
so it is AB for all these customers
73
74
00:04:14,720 --> 00:04:17,280
Now let us take out the last
74
75
00:04:17,536 --> 00:04:18,559
Five digits
75
76
00:04:22,143 --> 00:04:25,215
These are the five digits of the customer ID
76
77
00:04:25,727 --> 00:04:31,359
We want to take these out into a separate column. Let us go and write the query for that
77
78
00:04:31,871 --> 00:04:32,895
Select
78
79
00:04:36,479 --> 00:04:39,807
Customer ID customer name
79
80
00:04:41,087 --> 00:04:47,231
and substring
80
81
00:04:47,743 --> 00:04:51,071
Customer ID
81
82
00:04:51,327 --> 00:04:52,607
From 4
82
83
00:04:52,863 --> 00:04:57,471
it starts from the fourth character for 5 characters
83
84
00:04:57,727 --> 00:05:00,031
as
84
85
00:05:02,079 --> 00:05:03,359
Customer number
85
86
00:05:04,895 --> 00:05:09,503
From customer table
86
87
00:05:11,551 --> 00:05:13,855
Where substring
87
88
00:05:16,159 --> 00:05:20,255
Customer ID for 2 is AB
88
89
00:05:21,023 --> 00:05:25,887
So for this customer group only we find out the
89
90
00:05:26,143 --> 00:05:28,191
Last five digits
90
91
00:05:28,447 --> 00:05:32,543
So it should contain 10165 for the First row
91
92
00:05:33,823 --> 00:05:36,383
Let's select and run this query
92
93
00:05:38,943 --> 00:05:39,711
So can see
93
94
00:05:40,223 --> 00:05:42,783
10165 is the value mentioned here
94
95
00:05:45,599 --> 00:05:49,695
So this customer num column has the last five digits
95
96
00:05:50,463 --> 00:05:51,743
of the customer ID
96
97
00:05:53,023 --> 00:05:55,583
This is how we use substring to take out a
97
98
00:05:55,839 --> 00:05:58,399
Second string
98
99
00:05:58,655 --> 00:06:00,447
From a primary string
7598
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.