SQL Update Statement
Posted on
< Previous Next >
The UPDATE statement in SQL is used to modify existing records in a database table. It allows us to change the values of one or more columns in one or more rows of a table.
Update Syntax
UPDATE table_name
SET column1 = value1, column2 = value2, …
WHERE condition;
Here's an example:
Let's say we have a table named "student" with columns "id", "name", "email", "phone", and "address". We can use the UPDATE statement to change the value of the "phone" column for the row with an "id" of 1.
We would use the following statement:
UPDATE student SET phone = '123-456-7890' WHERE id = 1;
OUTPUT

We can also modify multiple columns in one UPDATE statement like below
UPDATE student SET phone = '123-456-7890', address = '123 Main St' WHERE id = 1;
OUTPUT

< Previous Next >