现在有四个表S(sno,sname,status,city)--供应商,P(pno,pname,color,weight)--零件表,J(jno,jname,city)--工程表,SPJ(sno,pno,jno,qty)--供应商产品信息表
请为三建工程项目建立一个供应情况的视图,包括供应商代码(SNO)、零件代码(PNO)、供应数量(QTY)。针对该视图完成下列查询:
(1) 找出三建工程项目使用的各种零件代码及其数量。
(2 找出供应商S1的供应情况(sno,snme,jno,jname,pno,jno.qty)。
try:
if exists(select * from sysobjects where name='view_spj')
drop view view_spj
go
create view view_spj
as
select a.jname,b.pno,b.qty from J as a, SPJ as b
where a.jno=b.jno and a.jname='三建工程'
if exists(select * from sysobjects where name='view_s1')
drop view view_s1
go
create view view_s1
as
select a.sno,a.snme,d.jno,d.jname,c.pno,b.qty
from S as a, SPJ as b,P as c, J as d
where a.snme='S1' and b.sno=a.sno and b.pno=c.pno
and b.jno=d.jno