我需要在from子句中使用select,但我一直獲得笛卡爾產品。笛卡爾產品和從條款中選擇
select
customer.customer_name
,orders.order_date
,order_line.num_ordered
,order_line.quoted_price
,part.descript
,amt_billed
from (select order_line.num_ordered*part.price as amt_billed
from order_line
join part
on order_line.part_num = part.part_num
) billed
,customer
join orders
on customer.customer_num = orders.customer_num
join order_line
on orders.order_num = order_line.order_num
join part
on order_line.part_num = part.part_num;
不要費心去看待其餘的太難。我已經知道如果刪除select子句中的from
子句和amt_billed
子查詢,我不會得到笛卡爾積。我在做什麼錯誤導致笛卡爾產品?
你忘記了與一個或多個其他表中加入你的子查詢。 '(你的子查詢),客戶...'它應該'(你的子查詢)asname加入客戶[或其他表]在...' –
你還必須在子查詢中添加一些可以讓你加入的列它與一些表。 –
@JorgeCampos當我嘗試在我的別名和子查詢之間使用'AS'時,它告訴我'ORA-00933:SQL命令沒有正確結束'。另外,如果我嘗試在連接中使用「billed」別名,它會告訴我'ORA-00942:table or view does not exist'。 –