Jason Clark
Jason Clark

Reputation: 1425

Getting error on alias name in SQL Server

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

Answers (1)

Pரதீப்
Pரதீப்

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

Related Questions