-- 1 selectdistinct sno from spj where jno=J1; -- 2 selectdistinct sno from spj where jno=j1 and pno=p1; -- 3 select sno from spj,p where jno=32and p.pno=spj.pno and color='red'; -- 4 select jno from j wherenotexists ( select*from s,p,spj where s.sno=spj.sno and p.pno=spj.pno and j.jno=spj.jno and color='red'and s.City='天津' ); -- 5 selectdistinct jno from spj t1 wherenotexists ( select*from spj t2 where t2.sno=s1 andnotexists ( select*from spj t3 where t3.jno=t1.jno and t3.pno=t2.pno ) )
-- 1 select sname,city from s; -- 2 select pname,color,weight from p; -- 3 selectdistinct jno from spj where sno=S1; -- 4 select pname,qty from spj,p where p.pno=spj.pno and jno=J2; -- 5 selectdistinct pno from spj,s where s.City='上海'and s.sno=spj.sno; -- 6 selectdistinct jname from j,spj,s where s.City='上海'and spj.sno=s.Sno and j.jno=spj.jno; -- 7 selectdistinct jno from spj wherenotexists( select*from s where spj.sno=s.sno and s.city='天津' ); -- 8 update p set color='blue'where color='red'; -- 9 update s set sno=S3 where sno in( select sno from spj where sno=S5 and jno=J4 and pno=p6 ); -- 10 deletefrom s where sno=S2; -- 11 insertinto spj values (S2,J6,P4,200);
4、
--createview myview (sno,pno,qty) as
(
select sno,p.pno,qty from spj,p where s.pno=spj.pno and jname='三建工程'
);
-- (1)select pno,sum(qty) from myview groupby pno;
-- (2)select*from myview where sno=S1;