box-o-sand/oldstuff/lsqlthw-remnants/ex8.sql

19 lines
357 B
MySQL
Raw Normal View History

2014-03-09 19:40:21 +00:00
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;
2014-03-09 22:54:14 +00:00
DELETE FROM person_pet
WHERE pet_id NOT IN (
2014-03-09 19:40:21 +00:00
SELECT id FROM pet
);
SELECT * FROM person_pet;