oracle中pr与po关系,关于PO 和PR 的联系问题

还有一种简单简单的办法,就是把pr_line和pr_header表连在一起,用括号括起来,作为一个子查询,去和po_line_locations_all做外关联

--以上是网友ideal 的提议.

Ideal 说:

你连接得不对。不知要连pr_line表,其他的地方也要加上外联结

--他说的原因.我想也是这样,一定是哪里有外连接,而我并不清楚.

所以还是采用他的建议;就是把pr_line和pr_header表连在一起,用括号括起来,作为一个子查询,去和po_line_locations_all做外关联

关于外连接以前只是字面上的理解,现在遇到了,才知道数据库的基础知识重要.再次感慨一下.[@more@]

以前一直想解决的就是输PO号,能购查询出来转化而来的PR号,最开始的研究结果是:

采购单找到请购单

通过采购单找到请购单的过程非常麻烦:

/* Formatted on 2006/03/30 14:35 (Formatter Plus v4.8.6) */

SELECTpod.req_header_reference_num,prh.segment1

FROM

po_headers_all poh,

po_distributions_all pod,

po_req_distributions_all prod,

po_line_locations_all poll,

po_requisition_lines_all prl,

po_requisition_headers_all prh

WHEREprh.requisition_header_id=prl.requisition_header_id

ANDprod.requisition_line_id=prl.requisition_line_id

ANDprod.distribution_id = pod.req_distribution_id

ANDpoll.line_location_id=pod.line_location_id

ANDpoll.po_header_id=poh.po_header_id

ANDpoh.segment1='20500214'

涉及几个表相关联,具体是:

po_headers_all poh,--采购单头

po_distributions_all pod,--采购单分部

po_req_distributions_all prod,--请购单分部

po_line_locations_all poll,--

--这个表做什么的,还不清楚,但是如果连接采购单和请购单,必须通过此table

po_requisition_lines_all prl,--请购单行

po_requisition_headers_all prh--请购单行

再后来网友提示不需要采购单,请购单分布属性,那么就可以这样:

SELECTprh.segment1,pol.from_line_id,pol.*

FROMpo_lines_all pol,

po_headers_all poh,

po_line_locations_all poll,

po_requisition_headers_all prh,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值