Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:02,560 --> 00:00:05,376
In this video we will learn how to update
1
2
00:00:05,632 --> 00:00:07,168
The records in our table
2
3
00:00:07,936 --> 00:00:08,960
To update records
3
4
00:00:09,216 --> 00:00:11,264
Update query is used in SQL
4
5
00:00:12,032 --> 00:00:13,824
This is the syntax of update query
5
6
00:00:15,360 --> 00:00:16,640
It starts with update
6
7
00:00:16,896 --> 00:00:18,432
Then we mention the table name
7
8
00:00:19,456 --> 00:00:20,736
Then is the keywords set
8
9
00:00:21,504 --> 00:00:23,040
After this we mention
9
10
00:00:23,296 --> 00:00:24,320
The column
10
11
00:00:24,832 --> 00:00:26,880
And its value which is to be set
11
12
00:00:27,392 --> 00:00:29,440
We can specify multiple columns
12
13
00:00:29,952 --> 00:00:32,512
Then we can give where condition
13
14
00:00:32,768 --> 00:00:36,352
so we saw where condition to specify different conditions
14
15
00:00:36,864 --> 00:00:40,704
We can use where if you want to update particular records
15
16
00:00:40,960 --> 00:00:44,800
If you want to update the whole table we may not use the where condition
16
17
00:00:45,824 --> 00:00:48,640
Let us look at some of the examples of update query
17
18
00:00:50,944 --> 00:00:51,968
let us say
18
19
00:00:52,736 --> 00:00:54,784
We want to update the age
19
20
00:00:55,552 --> 00:00:59,136
And the last name of the customer whose customer ID is 2
20
21
00:00:59,648 --> 00:01:03,488
So we go to the database and we look at the table
21
22
00:01:04,000 --> 00:01:09,120
let us see the customer with customer ID 2
22
23
00:01:09,376 --> 00:01:15,520
Customer table where cust ID 2
23
24
00:01:24,736 --> 00:01:26,528
So this customer is
24
25
00:01:26,784 --> 00:01:27,808
23 years old
25
26
00:01:28,320 --> 00:01:30,624
And the last name of this customer is missing
26
27
00:01:30,880 --> 00:01:33,696
If you want to add the last name and
27
28
00:01:33,952 --> 00:01:36,000
Change the age to 17 years
28
29
00:01:36,512 --> 00:01:41,120
This is how we do it we write update
29
30
00:01:43,168 --> 00:01:49,312
Table name
30
31
00:01:49,568 --> 00:01:52,640
then we write set
31
32
00:01:52,896 --> 00:01:57,248
Specify the column name which is last name
32
33
00:01:59,552 --> 00:02:03,136
then we give it the value of Pe
33
34
00:02:04,416 --> 00:02:06,464
Then
34
35
00:02:07,232 --> 00:02:10,304
We specify age column
35
36
00:02:10,560 --> 00:02:16,704
And give it a value of 17 where
36
37
00:02:16,960 --> 00:02:21,312
customer ID is 2
37
38
00:02:21,824 --> 00:02:24,128
Let us run this
38
39
00:02:26,176 --> 00:02:27,200
1
39
40
00:02:27,968 --> 00:02:30,272
Value updated. let us go and check
40
41
00:02:32,576 --> 00:02:36,928
You can see last name of the customer is updated to Pe
41
42
00:02:37,440 --> 00:02:39,232
And age is now 17
42
43
00:02:41,280 --> 00:02:44,096
Now if you want to update email ids
43
44
00:02:44,608 --> 00:02:45,632
Of customers
44
45
00:02:45,888 --> 00:02:49,728
Whose first name is Gee or
45
46
00:02:49,984 --> 00:02:51,520
Small cased gee
46
47
00:02:55,104 --> 00:02:56,640
You can see in our table
47
48
00:02:57,408 --> 00:02:58,688
If you search
48
49
00:02:59,200 --> 00:03:02,016
Customers with name gee
49
50
00:03:02,528 --> 00:03:08,672
Let us get all the customer names from customer table
50
51
00:03:14,048 --> 00:03:20,192
Let us run this to look at our data
51
52
00:03:20,448 --> 00:03:21,472
Table first
52
53
00:03:26,848 --> 00:03:30,688
You can see that there are four customers with first name gee
53
54
00:03:31,456 --> 00:03:32,736
And one of them
54
55
00:03:32,992 --> 00:03:36,320
As the name gee in small case
55
56
00:03:37,344 --> 00:03:42,720
For all these four customers we want to update the email id to gee
56
57
00:03:43,488 --> 00:03:45,024
@ xyz.com
57
58
00:03:45,792 --> 00:03:47,328
So how to do that
58
59
00:03:47,584 --> 00:03:49,632
We will write the update query
59
60
00:03:49,888 --> 00:03:56,032
Update customer table
60
61
00:03:59,360 --> 00:04:04,224
Set
61
62
00:04:04,480 --> 00:04:08,064
Email id to gee
62
63
00:04:08,320 --> 00:04:14,464
@ xyz.com where
63
64
00:04:15,744 --> 00:04:17,791
First name
64
65
00:04:18,047 --> 00:04:21,375
is Equal to
65
66
00:04:22,399 --> 00:04:23,423
Gee
66
67
00:04:24,191 --> 00:04:30,335
in camel case and then Gee in small case
67
68
00:04:34,175 --> 00:04:36,991
You can notice that we are using or operator
68
69
00:04:37,247 --> 00:04:41,855
to give two conditions at the same time
69
70
00:04:42,111 --> 00:04:45,183
let us run this
70
71
00:04:46,463 --> 00:04:48,511
and let us run the select query again
71
72
00:04:54,655 --> 00:04:55,935
you can see
72
73
00:04:56,703 --> 00:04:57,983
for the customers
73
74
00:04:59,263 --> 00:05:02,079
The last four customers with name gee
74
75
00:05:03,103 --> 00:05:06,943
All four have the same email id which is gee @
75
76
00:05:07,199 --> 00:05:08,479
Xyz.com
76
77
00:05:09,247 --> 00:05:13,599
This was not the email ID when this table was created earlier
77
78
00:05:15,647 --> 00:05:19,231
That's how we update the rows of a datatable
78
79
00:05:19,999 --> 00:05:22,047
Next you will learn how to delete
79
80
00:05:22,559 --> 00:05:24,607
Rows or records from a Table
5690
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.