bing
Flat 10% & upto 50% off + 10% Cashback + Free additional Courses. Hurry up
×
UPTO
50%
OFF!
Intellipaat
Intellipaat

Update command in SQL

In this tutorial section, we will discuss on what is an UPDATE query in SQL and how to update records using SQL UPDATE query in a SQL Table with a Demo.

Watch this Update Query in SQL video

A Brief Introduction to the UPDATE Query in SQL

The UPDATE command in SQL is used to modify or change the existing records in a table. If we want to update a particular value, then we use the WHERE clause along with the UPDATE clause.

Syntax

UPDATE table_name
SET col1=val1, col2=val2…
[Where condition];

where UPDATE, SET, and WHERE are the keywords, table_name is the name of the table you want update, col1, col2, … are the columns considered to be updated, val1, val2, … assign new values, and the condition section is where the condition is given, followed by a semicolon.

  • • Let’s update some records of the employee table using Update command in SQL
UPDATE employee
SET e_age=42
WHERE e_name=’sam’;

A Brief Introduction to the UPDATE Statement

  • After writing the query, click on the execute button to check for errors
  • Once the query is executed, a message appears like ‘Commands completed successfully’
  • Let’s check the update
SELECT * from employee;

A Brief Introduction to the UPDATE Statement step 2

  • After writing the query, click on the execute button to check for errors
  • Once the query is executed, a message appears like ‘Commands completed successfully’

Let’s now change the department value of all the female employees

UPDATE employee
SET e_dept=’tech’
WHERE e_gender=’female’;

A Brief Introduction to the UPDATE Statement step 3

  • After writing the query, click on the execute button to check for errors
  • Once the query is executed, a message appears like ‘Commands completed successfully’
  • Let’s check the update

SELECT * from employee;

A Brief Introduction to the UPDATE Statement step 4

  • After writing the query, click on the execute button to check for errors
  • Once the query is executed, a message appears like ‘Commands completed successfully’

Let’s now update the e_salary of all employees

UPDATE employee
SET e_salary=’50000’;

A Brief Introduction to the UPDATE Statement step 5

  • After writing the query, click on the execute button to check for errors
  • Once the query is executed, a message appears like ‘Commands completed successfully’
  • Let’s check the update
SELECT * from employee; 

A Brief Introduction to the UPDATE Statement step 6

  • After writing the query, click on the execute button to check for errors
  • Once the query is executed, a message appears like ‘Commands completed successfully’

This brings us to the end of this tutorial section, and you’re ready for updating your database with the Update query in SQL.

Previous Next

Download Interview Questions asked by top MNCs in 2019?

"0 Responses on UPDATE Query in SQL"

    100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.
    top

    Sales Offer

    Sign Up or Login to view the Free UPDATE Query in SQL.