Advertisement
horozov86

Delete Exam 3 (Take into consideration that there might be conflicts with foreign key constraints.)

Oct 13th, 2023
1,191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Delete records from referencing tables first
  2. DELETE FROM board_games
  3. WHERE publisher_id IN (
  4.     SELECT id
  5.     FROM publishers
  6.     WHERE address_id IN (
  7.         SELECT id
  8.         FROM addresses
  9.         WHERE town LIKE 'L%'
  10.     )
  11. );
  12.  
  13. DELETE FROM publishers
  14. WHERE address_id IN (
  15.     SELECT id
  16.     FROM addresses
  17.     WHERE town LIKE 'L%'
  18. );
  19.  
  20. -- Delete records from addresses table
  21. DELETE FROM addresses
  22. WHERE town LIKE 'L%';
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement