无法弄清楚为什么我不能执行此连接,过去我做了很多类似的事情。我想念什么吗?
SELECT *
FROM THB_View.PCM_PCM_BASE base
LEFT OUTER JOIN THB_View.PCM_PCM_BASE_REOCCUR rec
LEFT OUTER JOIN THB_View.ATV atv ON base.PCM_TAG = atv.ATV_OCCURRING_PCM_TAG
ON base.RECORD_KEY = rec.RECORD_KEY
WHERE
base.PCM_STATUS = 'ENROUTE'
AND rec.PCM_HRC_TAG IS NULL OR rec.PCM_HRC_TAG = ''
AND rec.PCM_EQP_TAG IS NULL OR rec.PCM_EQP_TAG = ''
错误发生在SQL语句的第5行base.PCM_TAG
答案 0 :(得分:0)
您的from子句不是编写join
的典型方法。这是允许的,但这会影响标识符的范围。本质上,这被解释为:
from THB_View.PCM_PCM_BASE base left join
(THB_View.PCM_PCM_BASE_REOCCUR rec left join
THB_View.ATV atv
on base.PCM_TAG = atv.ATV_OCCURRING_PCM_TAG
)
on base.RECORD_KEY = rec.RECORD_KEY
其中解释了为什么无法识别base
。
只需在对表join
进行编辑之后,以on
条件编写join
的标准方法:
from THB_View.PCM_PCM_BASE base left join
THB_View.PCM_PCM_BASE_REOCCUR rec
on base.RECORD_KEY = rec.RECORD_KEY left join
THB_View.ATV atv
on base.PCM_TAG = atv.ATV_OCCURRING_PCM_TAG