Home » SQL

SQL - UPDATE Statement (to update record in table)

SQL - UPDATE Statement: In this article, we are going to learn how to update a record using ‘UPDATE’ statement in SQL.
Submitted by Shubham Singh Rajawat, on November 13, 2017

Update statement is used to update/change any data/record that already exists in a table.

Syntax:

UPDATE table_name SET column1=value1, column2=value2, column3=value3, ...
WHERE condition;

Here,

  • table_name : name of the table into which we want to insert data.
  • column1, column2, ... : names of the columns/fields.
  • value1, value2, ... : values of the column/fields specified.
  • condition: it is the condition that defines which data is going to be updated.

We can also update multiple rows/records at a time by the changing the condition in 'WHERE clause'.

sql - update command example

Examples:

1) To update the name of the student whose Enroll_No is 3

UPDATE Student SET Student_name = 'Vaibhav' WHERE Enroll_No = 3;

This will update the name of the student to Vaibhav whose Enrollment number is 3

sql - update command example 1

2) To update city of all the students to Delhi

UPDATE Student SET City = 'Delhi';

This will update the name of the student to Vaibhav whose Enrollment number is 3

sql - update command example 2





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL







Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.