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
UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;
SQL SET with Specific Row Example
This query updates the city and specialty of the doctor with doctor_id = 1.
UPDATE Doctors SET specialty = 'Pediatrics' 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’.
UPDATE Patients SET gender = 'Unknown' WHERE last_name = 'Smith';
