Select from where select ssname from sailors s

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: E SELECT S.sname FROM Sailors S, Reserves R, Boats B WHERE S.sid = R.sid AND R.bid = B.bid AND B.color = ‘red’ red’ INTERSECT SELECT S2.sname FROM Sailors S2, Boats B2, Reserves R2 WHERE S2.sid = R2.sid AND R2.bid = B2.bid AND B2.color = ‘green’; green’ S.sname Sailors S, Reserves R, Boats B S.sid = R.sid AND R.bid = B.bid AND B.color = ‘red’ red’ AND S.sid IN ( SELECT S2.sid FROM Sailors S2, Boats B2, Reserves R2 WHERE S2.sid = R2.sid AND R2.bid = B2.bid AND B2.color = ‘green’); green’ INTERSECT is not supported in MySQL. MySQL. 39 Query Examples (continued) (Q9) 40 Query Examples (continued) Find names of sailors who have reserved all boats. (Q9) Find names of sailors who have reserved all boats. SELECT S.sname FROM Sailors S WHERE NOT EXISTS (( SELECT B.bid FROM Boats B) EXCEPT (SELECT R.bid FROM Reserves R WHERE R.sid=S.sid)); R.sid= S.sid)); SELECT FROM WHERE 41 S.sname Sailors S NOT EXISTS (( SELECT B.bid FROM Boats B) WHERE NOT EXISTS (SELECT R.bid FROM Reserves R WH...
View Full Document

This note was uploaded on 10/15/2012 for the course CSE 4503 taught by Professor Edallen during the Fall '12 term at Mississippi State.

Ask a homework question - tutors are online