你好,我正试图从Product_descriptions表中添加一个Translated_Name列到我当前的查询中,该查询已经连接了两个表,但是Translated_name列是一个类型为NVARCHAR2的列。我应该使用内联接,还是我完全错了?
select order_mode,customer_id,product_id from ORDERS
inner join ORDER_items on order_items.ORDER_ID=Orders.ORDER_ID
where exists(select customer_id from customers where orders.customer_id=customers.customer_id)
inner join product_descriptions on product_descriptions.translated_name = Orders.Customer_id
列表中的 "翻译名称 "列是一个类型为NVARCHAR2的列。where
子句在后 join
s:
select
order_mode,
customer_id,
product_id
from orders o
inner join order_items oi
on oi.order_id = o.order_id
inner join product_descriptions pd
on pd.translated_name = o.customer_id
where exists(
select 1
from customers c
where o.customer_id = c.customer_id
)
注:
表的别名使查询更容易读和写。
你应该限定列中的 from
子句,并使用它们所属表的别名。
我对加入条件有很大的怀疑。product_descriptions
,其中包括 customer_id
;你可能需要复习一下(在不了解你的表结构的情况下,无法判断正确的条件是什么)。