SQL SET Keyword
The SET command is used with the UPDATE statement to specify which columns should be updated and what new values they should receive.
Note: Be careful when using
UPDATE
without aWHERE
clause — it will update all records in the table.
SQL SET Syntax
SQL
x
1
UPDATE table_name
2
SET column1 = value1, column2 = value2, ...
3
WHERE condition;
SQL SET with Specific Row Example
This query updates the city and specialty of the doctor with doctor_id = 1.
SQL
1
1
UPDATE Doctors
2
SET specialty = 'Pediatrics'
3
WHERE doctor_id = 1;

SQL SET with Multiple Rows Example
This query updates the gender field to ‘Unknown’ for all patients whose last name is ‘Smith’.
SQL
1
1
UPDATE Patients
2
SET gender = 'Unknown'
3
WHERE last_name = 'Smith';
