Skip to content

Instantly share code, notes, and snippets.

@michalkortas
Created December 23, 2019 09:01
Show Gist options
  • Save michalkortas/2bc988ee6554119ea464fc811fabc1e0 to your computer and use it in GitHub Desktop.
Save michalkortas/2bc988ee6554119ea464fc811fabc1e0 to your computer and use it in GitHub Desktop.
delete from table with references
delete from files
where files.file_id
in (
select file_id from (select * from files) as removed_files left join addresses on removed_files.addresses_id = addresses.id
where addresses.id is null
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment