I have this query:
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);
And I get the error "Column 'PACId' in where clause is ambiguous."
I have tried this query before, with other data and I had no issues. What's going on?
Please let me know if you need more information.