****题三
Select sno from spj
Where jno=‘J1';
第
4
题
1.
求供应工程
J1
零件的供应商号码
SNO
。
2.
求供应工程
J1
零件
P1
的供应商号码
SNO
。
Select sno from spj
Where
jno=‘J1' and pno=‘P1';
1
3.
求供应工程
J1
零件为红色的供应商号码。
Select sno from spj, p
Where = and jno=‘J1' and
color=‘
红'
;
或:
Select sno from spj
Where jno =‘J1' and pno in
(Select pno from p
where color=‘
红'
);
2
4.
求没有使用天津供应商生产的红色零件的工程号
JNO
。
Select jno
From j
Where not exists
(Select *
From spj, s, p
where = and
=
and = and =‘
天津'
and =‘
红'
);
3
5.
求至少用了供应商
S1
所供应的全部零件的工程号
JNO
。
即查找:不存在这样的零件
y
,供应商
S1
供应了
y
,而工程
x
为选用
y
。
Select distinct jno
From spj z
Where not exists
(select *
from spj x
where sno=‘S1'
and not exists
(select *
from spj y
where = and =));
4
第
5
题
1.
找出所有供应商的姓名及其所在城市。
Select sname, city
from s;
2.
找出所有零件的名称、颜色、重量。
Select pname, color, weight
from p;
3.
找出使用供应商
S1
所供应零件的工程项目代码。
Select jno
from spj
where sno=‘S1';
5
4.
找出工程项目
J2
所使用的各种零件的名称及其
数量。
Select ,
from p, spj
where = and =‘J2';
5.
找出上海厂商供应的所有零件的代码。
Select distinct pno
from spj
where sno in
(Select sno
from s
where city=‘
上海'
);
6
6.
找出使用上海产的零件的
数据库答案第三章习题参考答案ppt课件 来自淘豆网www.taodocs.com转载请标明出处.