升级旧的 mysql 查询出错。错误代码:1054。'on 子句中的未知列 'VWNM.VWNM_VehWoNumID'

Upgarde an old mysql query &getting errors. Error Code: 1054. Unknown column 'VWNM.VWNM_VehWoNumID' in 'on clause

use ezmweb;
SELECT VWNM_VehWONo, SPM.SPM_ServProfID, STM_ServiceTypeTitle, SPM_ProTitle, VOUnSWO.VOUnSWO_VehWoNumID, 
VOUnSWO.VOUnSWO_ServProfServTypeID, VWCOI_CustContact ,VNM.VNM_VehName, VWCOI.VWCOI_CustAddr AS CuM_CustAddr, 
VWCOI.VWCOI_ZipCode AS CuM_ZipCode, VWCOI.VWCOI_CustCity AS CuM_CustCity, VWCOI.VWCOI_CustPhone AS CuM_CustPhone, 
VWCOI.VWCOI_StateID AS CuM_StateID, VWCOI.VWCOI_CountryID AS CuM_CountryID,VWCOI_CustID AS CuM_CustID, 
VWM.VWM_LabourHrs, VWM.VWM_LabourCost, VWM.VWM_PartsMatCost , VWM.VWM_VehDownTime, VWM.VWM_ActualUsage , 
VWM.VWM_MaintEndDt, VWM.VWM_MaintStartDt, VWM.VWM_WoMode, VWM.VWM_VehRefNotes, VWM.VWM_PerformedBy,
VWM.VWM_AssignedBy, VWOE.VWOE_Exceptions, VWOE.VWOE_ExceptionTemp,  VWON.VWON_Notes, VTS.VTS_VehNumber, 
VTS.VTS_Comments, VTS.VTS_VIN, VTS.VTS_YearBuilt, VTS.VTS_VehMake, VTS.VTS_SeatingCapacity, VTS.VTS_Transmission, 
VTS.VTS_VehNumber, VTS.VTS_AdvNoticeFlag, VTS.VTS_StartUsage, VTS.VTS_StartDate, VTS.VTS_Comments, 
VTS.VTS_DueDateOption, VTS.VTS_VIN, VTS.VTS_RegisteredTo, VTS.VTS_LicensePlate, VTS.VTS_StateID, VWOAT_AssignedTo, 
CWR.CWR_ReqTitle, CWR.CWR_ReqDesc, CWR.CWR_ReqDt, CWR.CWR_CustID, CWR.CWR_WrokReqID, VTS.VTS_VehToServiceID 
FROM tbl_VehToService AS VTS, tbl_VehWOCustOthInfo AS VWCOI,tbl_VehNameMaster AS VNM, 
tbl_VehWOMaster AS VWM, tbl_VehWONumMaster AS VWNM, tbl_VehOpenUnSchedWO AS VOUnSWO
left join tbl_VehWONotes        AS VWON  ON VWON.VWON_VehWoNumID = VOUnSWO.VOUnSWO_VehWoNumID
left join  tbl_VehWOExcep       AS VWOE  ON VWOE.VWOE_VehWoNumID = VOUnSWO.VOUnSWO_VehWoNumID
left join tbl_VehWOAssignTo     AS VWOAT ON VWOAT.VWOAT_VehWoNumID = VWNM.VWNM_VehWoNumID
left join tbl_VehOpenWoReq      AS VOWR  ON VOWR_VehWoNumID = VWNM.VWNM_VehWoNumID
left join tbl_CustWorkReq       AS CWR   ON CWR.CWR_WrokReqID = VOWR_WrokReqID
left join tbl_ServProfServType  AS SPST  ON SPST.SPST_ServProfServTypeID = VOUnSWO.VOUnSWO_ServProfServTypeID
left join tbl_ServProfMaster    AS SPM   ON SPM.SPM_ServProfID = SPST.SPST_ServProfID
left join tbl_ServiceTypeMaster AS STM   ON STM_ServiceTypeID = SPST.SPST_ServiceTypeID  
WHERE VOUnSWO.VOUnSWO_VehToServiceID = VTS.VTS_VehToServiceID AND  VTS.VTS_VehToServiceID='7919' AND VOUnSWO.VOUnSWO_ServProfServTypeID IS NULL AND VOUnSWO.VOUnSWO_VehWoNumID = VWCOI.VWCOI_VehWoNumID AND VOUnSWO.VOUnSWO_VehWoNumID = VWM.VWM_VehWoNumID AND VWCOI.VWCOI_VehWoNumID ='41962' AND VTS.VTS_VehNameID = VNM.VNM_VehNameID AND VWCOI.VWCOI_VehWoNumID = VWNM.VWNM_VehWoNumID

不要混用显式和隐式联接!始终如一地使用显式连接:

SELECT ...
FROM tbl_VehToService AS VTS
INNER JOIN tbl_VehOpenUnSchedWO AS VOUnSWO ON VOUnSWO.VOUnSWO_VehToServiceID = VTS.VTS_VehToServiceID
INNER JOIN tbl_VehWOCustOthInfo AS VWCOI   ON VOUnSWO.VOUnSWO_VehWoNumID = VWCOI.VWCOI_VehWoNumID
INNER JOIN tbl_VehNameMaster    AS VNM     ON VTS.VTS_VehNameID = VNM.VNM_VehNameID
INNER JOIN tbl_VehWOMaster      AS VWM     ON VOUnSWO.VOUnSWO_VehWoNumID = VWM.VWM_VehWoNumID
INNER JOIN tbl_VehWONumMaster   AS VWNM    ON VWCOI.VWCOI_VehWoNumID = VWNM.VWNM_VehWoNumID
LEFT JOIN tbl_VehWONotes        AS VWON    ON VWON.VWON_VehWoNumID = VOUnSWO.VOUnSWO_VehWoNumID
LEFT JOIN  tbl_VehWOExcep       AS VWOE    ON VWOE.VWOE_VehWoNumID = VOUnSWO.VOUnSWO_VehWoNumID
LEFT JOIN tbl_VehWOAssignTo     AS VWOAT   ON VWOAT.VWOAT_VehWoNumID = VWNM.VWNM_VehWoNumID
LEFT JOIN tbl_VehOpenWoReq      AS VOWR    ON VOWR_VehWoNumID = VWNM.VWNM_VehWoNumID
LEFT JOIN tbl_CustWorkReq       AS CWR     ON CWR.CWR_WrokReqID = VOWR_WrokReqID
LEFT JOIN tbl_ServProfServType  AS SPST    ON SPST.SPST_ServProfServTypeID = VOUnSWO.VOUnSWO_ServProfServTypeID
LEFT JOIN tbl_ServProfMaster    AS SPM     ON SPM.SPM_ServProfID = SPST.SPST_ServProfID
LEFT JOIN tbl_ServiceTypeMaster AS STM     ON STM_ServiceTypeID = SPST.SPST_ServiceTypeID  
WHERE  
    VTS.VTS_VehToServiceID='7919' 
    AND VOUnSWO.VOUnSWO_ServProfServTypeID IS NULL  
    AND VWCOI.VWCOI_VehWoNumID ='41962'