SQL UPDATE Keyword
The UPDATE command is used to modify existing rows in a table. It allows you to change one or more column values for rows that match a specified condition.
Important: Be careful when using
UPDATE
without aWHERE
clause — it will update all rows in the table.
SQL UPDATE Syntax
SQL
x
1
UPDATE table_name
2
SET column1 = value1, column2 = value2, ...
3
WHERE condition;
SQL UPDATE Single Row Example
This query updates the specialty of the doctor with doctor_id = 1.
SQL
1
1
UPDATE Doctors
2
SET specialty = 'Dermatology'
3
WHERE doctor_id = 1;

SQL UPDATE Multiple Rows Example
This query sets the gender of all patients with last name ‘Garcia’ to ‘Female’.
SQL
1
1
UPDATE Patients
2
SET gender = 'Female'
3
WHERE last_name = 'Garcia';
