查询有效,但我被要求以连接运算符样式重写它。
SELECT pr.ProdName, pr.ProdPrice
FROM Product pr, OrderTbl ord, OrdLine ol, Customer cu
WHERE pr.ProdNo=ol.ProdNo
AND ord.OrdNo=ol.OrdNo
AND cu.CustNo=ord.CustNo
AND cu.CustNo='C2388597'
AND ord.OrdDate BETWEEN '01-Jan-04' AND '31-Jan-04';
我刚刚开始使用Oracle,所以我不确定如何。我想我应该使用INNER JOINS,但我不确切知道如何。有人可以帮帮我吗?
答案 0 :(得分:1)
你绝对应该阅读joins,但这里是如何将这种交叉连接方式转换为内连接
SELECT pr.ProdName, pr.ProdPrice
FROM Product pr
INNER JOIN OrdLine ol ON pr.ProdNo=ol.ProdNo
INNER JOIN OrderTbl ord ON ord.OrdNo = ol.OrdNo
INNER JOIN Customer cu ON cu.CustNo=ord.CustNo
WHERE cu.CustNo='C2388597'
AND ord.OrdDate BETWEEN '01-Jan-04' AND '31-Jan-04';
答案 1 :(得分:0)
SELECT pr.ProdName, pr.ProdPrice
FROM Product pr
INNER JOIN OrdLine ol ON pr.ProdNo=ol.ProdNo
INNER JOIN OrderTbl ord ON ord.OrdNo = ol.OrdNo
INNER JOIN Customer cu ON cu.CustNo=ord.CustNo
WHERE cu.CustNo='C2388597'
AND ord.OrdDate BETWEEN '01-Jan-04' AND '31-Jan-04';