SQL Delete

The DELETE in SQL is used to remove existing records from a table. It allows you to delete one or […]

The DELETE in SQL is used to remove existing records from a table. It allows you to delete one or more rows based on specified conditions.

SQL Delete Syntax

SQL



Tutorials dojo strip

SQL Delete Example

This query deletes the record from the Patients table where the patient_id is 3. This means the entire record for the patient with patient_id = 3 will be removed from the table.

SQL




SQL Delete All Records Example

This query deletes all records from the Prescriptions table. This means that every entry in the Presciptions table will be removed, leaving the table empty.

SQL




SQL Delete Multiple Records Example

This query deletes all records from the Appointments table where the appointment_date is ‘2024-07-18’.

SQL




SQL Delete with Complex Conditions Example

This query deletes all records from the Patients table where the dob (date of birth) is earlier than ‘1980-01-01’.

SQL




SQL Delete with Subqueries Example

This query deletes all records from the Doctors table where the doctor_id is not present in the Appointments table. This means that any doctor who does not have any scheduled appointments will be removed from the Doctors table.

SQL




SQL Delete Visual Diagram




SQL Delete Labs

Tutorials dojo strip