Instead of deleting the child row and then writing another sql statement to delete the parent row I wanted to use one statement which will do both. FYI: we use Oracle database.
Update: I dont have a privilege to do DELETE ON CASCADE
Define your foreign keys with cascading deletes. Then you only need to delete the "parent" row.
delete from
(
select * from parent join child using (id)
where id = 1
)
WARNING! Will only delete where both parent AND child rows exist. Will NOT delete parents without children
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With