New Delhi, India
minigranth@gmail.com

SQL Update Command

Created with Sketch.

SQL Tutorial


[fblike]

SQL UPDATE Command : Introduction

  • SQL UPDATE command is a must have command while dealing with large data set. If by chance, any values in the table are inserted incorrectly, UPDATE command is there to help you out.
  • The UPDATE command is used to “Update or Modify” the existing values/records in the database tables. The records which needs to be modified can be a single one or multiple values which can be manipulated based upon the query used.
  • Also, with the help of SQL Clauses, modification on specific rows/values can also be done.

 

SQL UPDATE Command : Syntax

  • The syntax of UPDATE Command in SQL looks like :

 

This image describes the basic syntax of SQL update command that can be used in sql.

SQL UPDATE Command : Syntax

 


SQL UPDATE Command : Example

  • Consider the table of student_details and teacher_details.

Table : student_details

 

This image describes the select query results.

 

Table : teacher_details

 

This image describes the select query results.

 

Example-1 : Now if we wish to update marks of student “SAURAV”. Then, it can be done by executing the below query.

Query : UPDATE student_details SET marks = ’70’ where roll_no = 1;

Output :

 

This image describes the select query results.

 

Example-2 : If we wish to update the name of the teacher. Then it can be done by executing below query.

Query : UPDATE teacher_details SET name = ‘Ganesh’ where E.ID = 102;

Output :

 

This image describes the select query results.