Update statement in SQL

6 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€46.59
List Price:  €65.24
You save:  €18.64
£39.95
List Price:  £55.93
You save:  £15.98
CA$68.27
List Price:  CA$95.58
You save:  CA$27.31
A$76.51
List Price:  A$107.13
You save:  A$30.61
S$68.03
List Price:  S$95.25
You save:  S$27.21
HK$391.33
List Price:  HK$547.90
You save:  HK$156.56
CHF 45.60
List Price:  CHF 63.85
You save:  CHF 18.24
NOK kr550.06
List Price:  NOK kr770.13
You save:  NOK kr220.06
DKK kr347.49
List Price:  DKK kr486.51
You save:  DKK kr139.02
NZ$84.03
List Price:  NZ$117.65
You save:  NZ$33.61
د.إ183.60
List Price:  د.إ257.06
You save:  د.إ73.45
৳5,484.82
List Price:  ৳7,679.19
You save:  ৳2,194.37
₹4,167.13
List Price:  ₹5,834.32
You save:  ₹1,667.18
RM238.42
List Price:  RM333.81
You save:  RM95.39
₦65,297.93
List Price:  ₦91,422.33
You save:  ₦26,124.40
₨13,918.71
List Price:  ₨19,487.31
You save:  ₨5,568.59
฿1,846.97
List Price:  ฿2,585.90
You save:  ฿738.93
₺1,626.69
List Price:  ₺2,277.50
You save:  ₺650.80
B$257.91
List Price:  B$361.10
You save:  B$103.18
R942.93
List Price:  R1,320.17
You save:  R377.24
Лв91.05
List Price:  Лв127.48
You save:  Лв36.42
₩68,777.09
List Price:  ₩96,293.43
You save:  ₩27,516.34
₪190.37
List Price:  ₪266.53
You save:  ₪76.16
₱2,884.27
List Price:  ₱4,038.21
You save:  ₱1,153.93
¥7,839.25
List Price:  ¥10,975.59
You save:  ¥3,136.33
MX$862.02
List Price:  MX$1,206.90
You save:  MX$344.87
QR182.32
List Price:  QR255.26
You save:  QR72.94
P689.82
List Price:  P965.80
You save:  P275.98
KSh6,748.65
List Price:  KSh9,448.65
You save:  KSh2,700
E£2,394.60
List Price:  E£3,352.63
You save:  E£958.03
ብር2,846.33
List Price:  ብር3,985.10
You save:  ብር1,138.76
Kz41,775.97
List Price:  Kz58,489.70
You save:  Kz16,713.73
CLP$47,415.51
List Price:  CLP$66,385.51
You save:  CLP$18,970
CN¥362.26
List Price:  CN¥507.19
You save:  CN¥144.93
RD$2,936.27
List Price:  RD$4,111.01
You save:  RD$1,174.74
DA6,712.91
List Price:  DA9,398.61
You save:  DA2,685.70
FJ$112.97
List Price:  FJ$158.17
You save:  FJ$45.19
Q388.83
List Price:  Q544.39
You save:  Q155.56
GY$10,456.12
List Price:  GY$14,639.41
You save:  GY$4,183.28
ISK kr6,993.60
List Price:  ISK kr9,791.60
You save:  ISK kr2,798
DH505.76
List Price:  DH708.11
You save:  DH202.34
L888.32
List Price:  L1,243.72
You save:  L355.39
ден2,869.11
List Price:  ден4,016.98
You save:  ден1,147.87
MOP$402.79
List Price:  MOP$563.94
You save:  MOP$161.15
N$957.24
List Price:  N$1,340.22
You save:  N$382.97
C$1,839.29
List Price:  C$2,575.16
You save:  C$735.86
रु6,654.43
List Price:  रु9,316.74
You save:  रु2,662.30
S/186.47
List Price:  S/261.07
You save:  S/74.60
K192.50
List Price:  K269.52
You save:  K77.01
SAR187.49
List Price:  SAR262.50
You save:  SAR75.01
ZK1,315.66
List Price:  ZK1,842.03
You save:  ZK526.37
L231.86
List Price:  L324.63
You save:  L92.76
Kč1,171.86
List Price:  Kč1,640.70
You save:  Kč468.84
Ft18,288.87
List Price:  Ft25,605.88
You save:  Ft7,317.01
SEK kr544.90
List Price:  SEK kr762.91
You save:  SEK kr218
ARS$43,678.56
List Price:  ARS$61,153.48
You save:  ARS$17,474.92
Bs346.09
List Price:  Bs484.56
You save:  Bs138.46
COP$197,009.16
List Price:  COP$275,828.59
You save:  COP$78,819.43
₡25,122.12
List Price:  ₡35,172.98
You save:  ₡10,050.86
L1,233.97
List Price:  L1,727.65
You save:  L493.68
₲371,261.88
List Price:  ₲519,796.34
You save:  ₲148,534.45
$U1,917.12
List Price:  $U2,684.12
You save:  $U767
zł201.38
List Price:  zł281.95
You save:  zł80.57
Already have an account? Log In

Transcript

So now it's time to talk about the update reverse. So, yes, I'm talking about the UPDATE statement. So the UPDATE statement is used to modify the existing record in the table. Course. As you know, we have six records from students. As you know, this is these are the records.

Now I want to update this record how I'm saying I want to add the address in this field, six ID. Now how can you do that? First of all, you need the update, keyword update. Then they will learn and things to read and then to update the student table. Now I'm seeing set value equals to why I'm writing This comment, because two quotation sorry, because it's a string where you I'm going to add the string value. That's why, if you have a integer value, then you can add it like this.

Okay, now what I'm saying x y Zed my by using set and saying set address. That is I'm saying I'm going to update the record students. And now I'm going to set the value which value this value in this column. Right. If you execute this query, it will update the all the records because you are not specifying that which address you are going to update. So that's why Before going this or before updating any table, you have to use the where clause, which is unique ID.

Now I'm saying update record where s ID equals to six. As you as you know, this is the sixth ID, I'm saying, oh please update set the value x y Zed Mumbai, where the ID is six. Now, execute your query Ctrl Enter. And now show you how to select the static from students Ctrl Enter. As you can see, you have just updated the record moving so now by this, I am saying I'm going to update the record without the class what happens if you use the UPDATE statement without WHERE clause financing UPDATE students am saying set As address equals two, in this time I'm saying London only London without weight loss now execute your query Ctrl y and using Ctrl, enter because this is a data grid and you can you have two options basically, right click execute your query or press the record button and hit enter.

If you're working on Oracle and some other databases, you may have some other interfaces or some other class acuity. Now, I'm saying select static from student show me all the records hit the enter. So now as you can see, you have updated the London to all your records as you can see, now this is the difference so you have to specify Which a row you are going to upgrade and which column you are going for suppose even if you want to update two columns, how can you do that? I'm saying update the students. And now I'm saying set S address equals to four. Suppose I'm saying York, New York.

And now I'm saying karma and city equals to make sure equals to New York. Okay, now Control Enter, execute your query. Caller saying, hello. Now I'm saying that and sorry. You have to Use the comma okay now I don't enter now into static form students enter so now you can see it's showing you the records but without you have just executed theory without WHERE clause. So now I'm saying UPDATE students set as city sorry set city equals two parcels.

London and karma am saying that address equals to UK that means the United Kingdom and now I'm saying where ID equals two One. So now I'm saying I'm going to update to call up. So as you know, these are the columns and these are the values up and return and I'm going to update the record which has one ID now, I'm talking about this one. So now Ctrl Enter. Okay I have just executed. So now I am saying select the Steadicam students have all entered so now they can see you have just upgraded to record.

In this way you can perform the UPDATE statement. So I think this is enough for the next session we are going to cover some other topics. So thank you for watching.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.