急求:十万火急。。。一条SQL语句(70分)

  • 主题发起人 主题发起人 ydzi_
  • 开始时间 开始时间
Y

ydzi_

Unregistered / Unconfirmed
GUEST, unregistred user!
D表
DID DMemo
D1 ...
D2 ...
D3 ...

C表
CID BInfo C1 C2 C3 DID
C1 ... 1 2 3
C2 ... 4 5 6

V表
VID VNum VInfo1 VInfo2 EID
V1 1 ...
V2 4 ...

E表
EID EName
E1 ...
E2 ...

SELECT (SELECT A.AMemo FROM A, B WHERE B.AID = A.AID) AS AMemmo,
(SELECT C.CInfo1 AS 'CInfo1', C.CInfo2 AS 'CInfo2' FROM B, C WHERE
(C.CNum = (SELECT B1 FROM B)) OR (C.CNum = (SELECT B2 FROM B)) OR (C.CNum = (SELECT B3 FROM B))),
(SELECT E.EName FROM E WHERE E.EID = V.EID) AS EName FROM V
-- 当没有用 EXISTS 引入子查询时,在选择列表中只能指定一个表达式。

SELECT (SELECT A.AMemo FROM A, B WHERE B.AID = A.AID) AS AMemmo,
(SELECT C.CInfo1 AS 'CInfo1', C.CInfo2 AS 'CInfo2' FROM B, C WHERE
(C.CNum IN (SELECT B1 FROM B)) OR (C.CNum IN (SELECT B2 FROM B)) OR (C.CNum IN (SELECT B3 FROM B))),
(SELECT E.EName FROM E WHERE E.EID = V.EID) AS EName FROM V
-- 当没有用 EXISTS 引入子查询时,在选择列表中只能指定一个表达式。


SELECT (SELECT A.AMemo FROM A, B WHERE B.AID = A.AID) AS AMemmo,
(SELECT C.CInfo1 AS 'CInfo1' FROM B, C WHERE
(C.CNum = C.C1) OR (C.CNum = C.C2) OR (C.CNum = C.C3))),
(SELECT C.CInfo2 AS 'CInfo2' FROM B, C WHERE
(C.CNum = C.C1) OR (C.CNum = C.C2) OR (C.CNum = C.C3))),
(SELECT E.EName FROM E WHERE E.EID = V.EID) AS EName FROM V
-- 子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。


谢谢
 
SELECT A.AMemo AS AMemmo, C.CInfo1 AS 'CInfo1', C.CInfo2 AS 'CInfo2',E.EName AS EName FROM A,B,C,D,E,V
WHERE B.AID = A.AID AND ((C.CNum = C.C1) OR (C.CNum = C.C2) OR (C.CNum = C.C3)) AND E.EID = V.EID
 
后退
顶部