Reputation: 105
So I am trying to run a statement in SSMS like:
SELECT Project.PROJNAME FROM PROJECT
JOIN SHIPMENT ON SHIPMENT.SNUM = SUPPLIERS.SNUM
JOIN PARTS ON PARTS.PNUM = SHIPMENT.PNUM
JOIN SUPPLIERS ON PROJECT.PROJNUM = SHIPMENT.PROJNUM
WHERE SUPPLIERS.SNAME='S1' AND SUPPLIERS.SNAME='S2'
However, when I do, I have an issue with the suppliers.snum portion on line 2 of the query. It tells me the multi-part identifier cannot be bound. I have looked at several ways to rectify the problem, but for some reason its just not sinking in for the understanding on the how and why. Could someone please explain how to fix this and why exactly the current way does not work? Thanks guys, cheers.
Upvotes: 0
Views: 34
Reputation: 24146
your query looks very strange for me, try this version with proper order:
SELECT Project.PROJNAME
FROM
PROJECT
JOIN
SHIPMENT
ON PROJECT.PROJNUM = SHIPMENT.PROJNUM
JOIN
PARTS
ON SHIPMENT.PNUM = PARTS.PNUM
JOIN
SUPPLIERS
ON SHIPMENT.SNUM = SUPPLIERS.SNUM
WHERE
SUPPLIERS.SNAME IN ('S1', 'S2')
Upvotes: 1