Reputation: 1425
Why I am getting an error for this code?
SELECT test.name, test2.name
FROM test AS p
INNER JOIN test2 AS d ON p.id = d.testid
I am learning alias on tables, but it throws this error:
Msg 4104, Level 16, State 1, Line 328
The multi-part identifier "test.name" could not be bound.
Where am I wrong?
Upvotes: 0
Views: 2452
Reputation: 93694
Because you have defined alias name to test
and test2
table. You need to use alias name to refer columns
SELECT p.name, d.name
FROM test as p
INNER JOIN test2 as d
ON p.id = d.testid
Upvotes: 3