(1)
select *
from S
where A='10';
(2)
select A,B
from S;
(3)
select A,B,S.C,S.D,E,F
from S,T
where S.C=T.C and S.D=T.D;
(4)
select *
from S,T
where S.C=T.C;
(5)
SELECT *
from S,T
where S.A
CREATE TABLE S (Sno C(2) UNIQUE,
Sname C(6) ,
Status C(2),
City C(4));
P表:
CREATE TABLE P(Pno C(2) UNIQUE,
Pname C(6),
COLOR C(2),
WEIGHT INT);
J表:
CREATE TABLE J(Jno C(2) UNlQUE,
JNAME C(8),
CITY C(4))
SPJ表:
CREATE TABLE SPJ(Sno C(2),
Pno C(2),
JNO C(2),
QTY INT))
习题6查询
(1)
SELECT DIST SNO
FROM SPJ
WHERE JNO=’J1’
(2)
SELECT DIST SNO
FROM SPJ
WHERE JNO='J1' AND PNO='P1'
(3)
SELECT SNO
FROM SPJ,P
WHERE JNO='J1' AND SPJ.PNO=P.PNO AND COLOR='红'
(3)
SELECT DIST JNO
FROM SPJ
WHERE JNO NOT IN (SELE JNO
FROM SPJ,P,S
WHERE S.CITY='天津'
AND COLOR='红'
AND S.SNO=SPJ.SNO
AND P.PNO=SPJ.PNO)
(4)先查询S1供应商供应的零件号
SELECT DIST PNO
FROM SPJ
WHERE SNO='S1';
再查询哪一个工程既使用P1零件又使用P2零件。
SELECT JNO
FROM SPJ
WHERE PNO='P1'AND JNO IN (SELECT JNO FROM SPJ WHERE PNO='P2');
SELECT SNAME,CITY
FROM S
(2)
SELECT PNAME,COLOR,WEIGHT
FROM P
(3)
SELECT DIST JNO
FROM SPJ
WHERE SNO='S1'
(4)
SELECT PNAME,QTY
FROM SPJ,P
WHERE P.PNO=SPJ.PNO AND SPJ.JNO='J2'
(5)
SELECT PNO
FROM SPJ,S
WHERE S.SNO=SPJ.SNO AND CITY='上海'
(6)
SELECT JNAME
FROM SPJ,S,J
WHERE S.SNO=SPJ.SNO AND S.CITY='上海' AND J.JNO=SPJ.JNO
(7)
SELECT DISP JNO
FROM SPJ
WHERE JNO NOT IN (SELECT DIST JNO
FROM SPJ,S
WHERE S.SNO=SPJ.SNO AND S.CITY='天津')
(8)
UPDATE P SET COLOR='蓝'
WHERE COLOR='红'
(9)
UPDATE SPJ SET SNO='S3'
WHERE SNO='S5' AND JNO='J4' AND PNO='P6'
(10)
1.DELETE FROM S WHERE SNO=’S2’
2.DELETE FROM SPJ WHERE SNO=‘S2’
(11)
INSERT INTO SPJ
VALUES(‘S2’,‘J6’,‘P4’,200)
SELECT DIST PNO,QTY
FROM VSP
(2)
SELECT DIST *
FROM VSP
WHERE SNO='S1'