80 likes | 205 Views
Answers:. a. select S# from SPJ where J#=J1 and. select S# from SPJ as SPJX where J#=J1 and exists. S# in (select S# from SPJ where J#=J2).
E N D
Answers: a. select S# from SPJ where J#=J1 and select S# from SPJ as SPJX where J#=J1 and exists S# in (select S# from SPJ where J#=J2) (select * from SPJ as SPJY where SPJ .J#=J2 and SPJY.S#=SPJX.S#)
Answers: b. select S# from SPJ where J#=any (select J# from J where CITY=‘ShangHai’ or CITY=‘BeiJing’)
Answers: c. select S# from S where S.CITY=‘ShangHai’ and S.S# in (select S# from SPJ where SPJ.J in (select J# from J where J.CITY = ‘ShangHai’)) where ‘ShangHai’ in (select CITY from J where SPJ.J# =J.J#)) where exists (select * from J where SPJ.J# =J.J# and CITY=‘ShangHai’))
Answers: d. select S# from S where CITY=‘BeiJing’ and ‘Red’ not in (select COLOR from P where P# in (select P# from SPJ where SPJ.S#=S.S#))
Answers: d. select S# from S where CITY=‘BeiJing’ and not exists (select * from SPJ where S.S#=SPJ.S# and exists (select P# from P where COLOR=‘Red’ and SPJ.P#=P.P#))
Answers: e. select J# from J where exists (select * from SPJ where J.J#=SPJ.J# and SPJ.S#=S1)
Answers: f. select SNAME from S where not exists (select * from P where not exists (select * from SPJ where S.S#=SPJ.S# and SPJ.P#=P.P#))
Answers: g. select S# from S where not exists g. select S# from SPJ group by S# having P# in (select * from SPJ as T where S#=‘S1’ and not exists (select P# from SPJ where S#=S1) (select * from SPJ as R where R.S#=S.S# and T.P#=R.P#))