INTERSECT 在SQL SERVERS7.0中的用法???
adu 2001-02-10 11:32:00 schema:
Sailors(sid;integer, sname:string, rating:real, age:real)
primary key(sid)
Boats(bid:integer, bname;string, color:string)
primary key(bid)
Reserves(sid:integer, bid integer,date:datetime)
primary key(sid,bid,date)
foreign key(sid,bid)
Find the name of Sailor who have server both red boat and green boat
SELECT S.sname
FROM Sailors As S
WHERE S.sid In
((SELECT R.sid
FROM Reserves As R ,Boats As B
WHERE R.bid =B.bid and B.color='red')
INTERSECT
(SELECT R2.sid
FROM Reserves As R2 ,Boats As B2
WHERE R2.bid =B2.bid and B2.color='green')
)
在sql server7.0中运行,说INTERSECT语法错误。
各位大虾,这个query在sql server7.0怎么写。
另外,我运行这个query是可行的。
Find the name of Sailor who have server both red boat or green boat
SELECT S.sname
FROM Sailors As S
WHERE S.sid In
((SELECT R.sid
FROM Reserves As R ,Boats As B
WHERE R.bid =B.bid and B.color='red')
UNION
(SELECT R2.sid
FROM Reserves As R2 ,Boats As B2
WHERE R2.bid =B2.bid and B2.color='green')
)