Hi Folks
Ran into this problem working on an application I'm writing, not sure how to get around it...
SELECT CatalogID FROM Catalog cat
LEFT JOIN Town tn ON cat.RouteIntOnAt = tn.TownCallSign
WHERE cat.PrintLoadSide1 = 'Y'
AND tn.townStagedArea = @Par1 --Name of Staging area
AND Cat.SessionSelect = ''
AND Cat.CatComm IN (SELECT LrCommodity FROM LoadRestrict WHERE lrTrainType = @Par2)
UNION
SELECT CatalogID FROM Catalog
WHERE PrintLoadSide1 = 'N'
AND RouteVerso <> 'Start at Industry'
and SessionSelect = ''
AND Cat.CatComm IN (SELECT LrCommodity FROM LoadRestrict WHERE lrTrainType = @Par2);
I'm getting an error on the bold part above; apparently it doesn't like me using Cat.CatComm twice. But I'm fairly sure it has something to do with the subquery being repeated. Any suggestions on how I can make this work? Thanks!
Craig
Ran into this problem working on an application I'm writing, not sure how to get around it...
SELECT CatalogID FROM Catalog cat
LEFT JOIN Town tn ON cat.RouteIntOnAt = tn.TownCallSign
WHERE cat.PrintLoadSide1 = 'Y'
AND tn.townStagedArea = @Par1 --Name of Staging area
AND Cat.SessionSelect = ''
AND Cat.CatComm IN (SELECT LrCommodity FROM LoadRestrict WHERE lrTrainType = @Par2)
UNION
SELECT CatalogID FROM Catalog
WHERE PrintLoadSide1 = 'N'
AND RouteVerso <> 'Start at Industry'
and SessionSelect = ''
AND Cat.CatComm IN (SELECT LrCommodity FROM LoadRestrict WHERE lrTrainType = @Par2);
I'm getting an error on the bold part above; apparently it doesn't like me using Cat.CatComm twice. But I'm fairly sure it has something to do with the subquery being repeated. Any suggestions on how I can make this work? Thanks!
Craig