Skip to content

Instantly share code, notes, and snippets.

@bartubozkurt
Created June 12, 2021 21:35
Show Gist options
  • Save bartubozkurt/1de270416a8389dca40234543a4d151a to your computer and use it in GitHub Desktop.
Save bartubozkurt/1de270416a8389dca40234543a4d151a to your computer and use it in GitHub Desktop.
This SQL Server DELETE example would delete all records in the employees table where there is a record in the contacts table whose contact_id is less than 100, and the contact_id matches the employee_id
DELETE FROM employees
WHERE EXISTS
( SELECT *
FROM contacts
WHERE contacts.contact_id = employees.employee_id
AND contacts.contact_id < 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment