The UPDATE in SQL is used to modify existing records in a table. It allows you to change one or more values in one or more rows of a table.
SQL Update Syntax
SQL
x
1
UPDATE table_name
2
SET column1 = value1, column2 = value2, ...
3
WHERE condition;
SQL Update Example
SQL Update Updating a Single Record Example
This query updates the contact_number to ‘555-9999’ for the patient with patient_id = 2 in the Patients table.
SQL
1
1
UPDATE Patients
2
SET contact_number = '555-9999'
3
WHERE patient_id = 2;

SQL Update Multiple Records Example
This query updates the status to ‘Rescheduled’ for all records in the Appointments table where the appointment_date is ‘2024-07-18’.
SQL
1
1
UPDATE Appointments
2
SET status = 'Rescheduled'
3
WHERE appointment_date = '2024-07-18';

SQL Update Multiple Columns Example
This query updates the contact_number to ‘555-1234’ and the dob (date of birth) to ‘1991-01-15’ for the patient with patient_id = 5 in the Patients table.
SQL
1
1
UPDATE Patients
2
SET contact_number = '555-1234', dob = '1991-01-15'
3
WHERE patient_id = 5;

SQL Update Visual Diagram
