Skip to main content

How do you update a record in a table?

Updating an existing record in a table is done with the UPDATE command.

Syntax:

sql
UPDATE Table_Name SET Field1 = Value1, Field2 = Value2, ... WHERE Condition;

Example:

sql
UPDATE Employees SET Age = 31, DepartmentID = 102 WHERE ID = 1;

Explanation:

  • UPDATE Employees, picks the table where we want to change data.
  • SET Age = 31, DepartmentID = 102, specifies which fields to update and to what values.
  • WHERE ID = 1, determines which specific record to change (without WHERE, every record in the table gets changed).

Notes

  • Always use WHERE, so you don't accidentally change every row.
  • One or several fields can be updated at once.

Put simply, UPDATE is the SQL command for changing data in existing records of a table.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.