From f12fbd7682e313debcad00a20897788d4ef7652d Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sun, 9 Mar 2014 15:40:21 -0400 Subject: [PATCH] lsqlthw ex8 --- lsqlthw-remnants/ex8.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lsqlthw-remnants/ex8.sql diff --git a/lsqlthw-remnants/ex8.sql b/lsqlthw-remnants/ex8.sql new file mode 100644 index 0000000..ed7f316 --- /dev/null +++ b/lsqlthw-remnants/ex8.sql @@ -0,0 +1,18 @@ +DELETE FROM pet WHERE id IN ( + SELECT pet.id + FROM pet, person_pet, person + WHERE + person.id = person_pet.person_id AND + pet.id = person_pet.pet_id AND + person.first_name = "Zed" +); + +SELECT * FROM pet; +SELECT * FROM person_pet; + +DELETE FROM person pet + WHERE pet id NOT IN ( + SELECT id FROM pet + ); + +SELECT * FROM person_pet;