How to use Update statement in SQL

The update SQL statement allows the user to modify the content of any existing record in a table. It basically has two clauses:

  • The set clause is used to define the new value to put into the column (or columns) to be updated.
  • The where clause is used to specify what are the rows to update. We can modify just one row of the table, a subset of rows, or we can modify all the records of the table.
-- John Smith receives a rise of 5000
Update Database_test_IB1.employee set salary = salary + 5000 
where last_name = ‘Smith’ and first_name = ‘John’;

-- The first_name of employee with emp_id equal to 1234 is set to Pierre.
Update Database_test_IB1.employee set first_name = 'Pierre'
where emp_id = 1234 ;

IN THIS PAGE