我正在尝试从5个不同的表中提取信息的选择查询,并且我在from部分中遇到错误。我已经尝试了几种代码变体,但没有任何工作。下面是代码和错误。
SELECT incident.incidentowner,
incident.qualitymember,
incident.purchasingmember,
incident.additionalmember,
incident.customername,
incident.customercontact,
incident.incidentid,
incident.stockcode,
incident.incidentdate,
incident.stocksupplier,
incident.customeraccountno,
incident.supplydate,
incident.incidentsite,
incident.depot,
incident.samplesent,
incident.quantity,
incident.incidentvalue,
incident.branchtransfer,
incident.hireorsale,
incident.quarantined,
incident.returnedtosupplier,
incident.replacedbysupplier,
incident.creditedbysupplier,
incident.incidentdescription,
containment.containment,
containment.containmentdate,
rootcause.rootcause,
rootcause.rootcausedate,
correctiveaction.correctiveaction,
correctiveaction.correctiveactiondate,
validation.validation,
validation.director,
validation.validationdate
FROM Incident
INNER JOIN containment ON
incident.incidentid = containment.incidentid
INNER JOIN rootcause ON
incident.incidentid = rootcause.incidentid
INNER JOIN correctiveaction ON
incident.incidentid = correctiveaction.incidentid
INNER JOIN validation ON
incident.incidentid = validation.incidentid
WHERE Incident.IncidentID = @incidentid
这会返回以下错误
Additional information: Syntax error (missing operator) in query expression
'incident.incidentid = containment.incidentid INNER JOIN rootcause ON
incident.incidentid = rootcause.incidentid INNER JOIN correctiveaction ON
incident.incidentid = correctiveaction.incidentid INNER JOIN validation ON
incident.incidentid = validation.inci'.
答案 0 :(得分:1)
需要额外的parantheses,谢谢微软
FROM (((Incident
INNER JOIN containment ON
incident.incidentid = containment.incidentid)
INNER JOIN rootcause ON
incident.incidentid = rootcause.incidentid)
INNER JOIN correctiveaction ON
incident.incidentid = correctiveaction.incidentid)
INNER JOIN validation ON
incident.incidentid = validation.incidentid