如何在mysql中解决正向引用?

时间:2018-11-01 07:30:04

标签: mysql

这是我的mysql查询。出现以下错误。如何解决?

select 
    p.P3_WOTypeId,
    p.P3_WOId,
    p3_WoNo,
    p3_wotype.P3_WOType,
    case when((
        SELECT P3_SubmissionCount
         from p3_woqmsmaster
         where p3_woqmsmaster.P3_WOID = P3_WOID
           and P3_ReviewType = P3_WOStatusDescription 
           and p.P3_WODisplay = 1
         order by P3_QMSId desc limit 1
    )) > 1
    then concat(p3_wostatusmaster.P3_WOStatusDescription,'_Rework')
    else p3_wostatusmaster.P3_WOStatusDescription
    End As P3_WOStatusDescription
from p3_womaster p
Join p3_wotype on (p3_wotype.P3_WOTypeId =  p.p3_WoTypeId)
where p.p3_WODisplay = 1
  and p.P3_workTemplateId ='19'
  and P3_WOId IN(
      select DISTINCT P3_WOId
      from p3_woqmsmaster
      where P3_SubmissionCount > 1
  )
  and p.p3_wostatusId in (2,3)

我遇到错误了

  

错误代码:1247。不支持引用'P3_WOStatusDescription'   (项目列表中的前向参考)0.000秒

如何解决?

1 个答案:

答案 0 :(得分:0)

您在p3_wostatusmaster.P3_WOStatusDescription语句中指的是case,但您从未加入p3_wostatusmaster。加入p3_wostatusmaster