Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT name FROM sailors
- WHERE Sid NOT IN (
- -- A sailor is disqualified if by attaching a boat,
- -- we obtain a tuple <sailor, boat> that is not in reserves
- SELECT s.Sid
- FROM sailors s, boats b
- WHERE (s.Sid, b.Bid) NOT IN (
- SELECT Sid, Bid FROM reserves
- )
- );
- -- Alternatively:
- SELECT name FROM sailors s
- WHERE NOT EXISTS (
- -- Not reserved boats
- (SELECT bid FROM boats)
- EXCEPT
- (SELECT r.bid FROM reserves r
- WHERE r.sid = s.sid)
- );
Add Comment
Please, Sign In to add comment