Skip to content
Advertisement

Tag: sql-delete

Delete rows depending on values from another table

How to delete rows from my customer table depending on values from another table, let’s say orders? If the customer has no active orders they should be able to be deleted from the DB along with their rows (done using CASCADE). However, if they have any active orders at all, they can’t be deleted. I thought about a PLPGSQL function,

Advertisement