box-o-sand/lsqlthw-remnants/ex8.sql
2014-03-09 15:40:21 -04:00

19 lines
357 B
SQL

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;