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

UPDATE Query in SQL 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 [videothumb class=\"col-md-12\" id=\"HyIGW3TsCgY\" alt=\"Update & Delete Using Join\"

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.

Go for this in-depth job-oriented SQL training Course now!

  • • 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

Enrol yourself for SQL certification and give a head-start to your career in SQL!

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

Still have queries? Come to Intellipaat’s SQL Community, clarify all your doubts, and excel in your career!

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.

Wish to crack SQL interviews? Intellipaat’s Top SQL Interview Questions are meant only for you!

Leave a Reply

Your email address will not be published. Required fields are marked *