"列名"在WHERE子句中是不明确的

时间:2014-07-29 05:04:53

标签: mysql

我有这个问题:

SELECT EquipmentNumber, EquipmentType, P.AreaCode AS Location, EquipDsc FROM MajorEquipment ME
 INNER JOIN PlantAreaCodes P ON ME.PACId = P.PACId WHERE
 (@EquipNumber IS NULL OR EquipmentNumber LIKE @EquipNumber)
 AND ((SELECT PACId FROM PlantAreaCodes WHERE AreaCode = @Location) IS NULL OR PACId = (SELECT PACId FROM PlantAreaCodes WHERE AreaCode = @Location))
 AND (@EquipType IS NULL OR EquipmentType LIKE @EquipType)
 AND (@Comments IS NULL OR EquipDsc LIKE @Comments);

我收到错误" Column' PACId'在where子句中含糊不清。"

我之前尝试过此查询,其他数据并没有问题。发生了什么事?

如果您需要更多信息,请与我们联系。

1 个答案:

答案 0 :(得分:1)

你应该预先设置模糊的列,
sql不知道,你想要什么ME.PACIdP.PACId

改变 ) IS NULL OR PACId = (SELECT => ) IS NULL OR ME.PACId = (SELECT