有人能指出我们下面的查询有什么问题吗?我有3张桌子。
1. Order Header - Order_header_id
2. Order Pricelist - order_header_id(fk),pricelist_id(fk)
3. Pricelist - pricelist_id,Name
我正在尝试使用下面的查询根据订单标题获取价目表名称,并且它会抛出“缺少右括号”错误。不确定我是否朝着正确的方向前进。
Select pricelist.Name from ORDER_HEADER
left outer join
(select order_pricelist.pricelist_id from order_pricelist on order_header.order_header_id = order_pricelist.order_header_id
left outer join
(select pricelist.name from pricelist) pricelist on order_pricelist.pricelist_id = pricelist.pricelist_id)
由于
答案 0 :(得分:0)
Select pricelist.Name from ORDER_HEADER
left outer join
(select pricelist_id, order_header_id from order_pricelist) op
ON order_header.order_header_id = op.order_header_id
left outer join
(select name,pricelist_id from pricelist) pr
ON op.pricelist_id = pr.pricelist_id
但实际上,你不需要这里的子查询,所以它可以是这样的:
Select pricelist.Name from ORDER_HEADER
left outer join order_pricelist op on order_header.order_header_id = op.order_header_id
left outer join pricelist pr on op.pricelist_id = pr.pricelist_id