The multi-part identifier "Table.column" could not be bound on Inner Join

时间:2015-09-01 21:23:10

标签: sql-server

Please, help me.

I have 2 tables: MainInfo (userName, pw)& BasicInfo (userName, birthday, phone). I do an query as follow:

SELECT MainInfo.userName, pw, birthday, phone
FROM MainInfo M INNER JOIN BasicInfo B
ON M.userName = B.userName

But it throw an error: The multi-part identifier "MainInfo.userName" could not be bound. What's wrong? I don't understand! I think about it very much, but still don't know why. Please help me!!

1 个答案:

答案 0 :(得分:1)

Once you have aliased your table, use the alias to use TWO PART names for columns. i.e [TableAlias].[ColumnName]

SELECT M.userName
      ,M.pw
      ,B.birthday
      ,B.phone
FROM MainInfo M INNER JOIN BasicInfo B
ON M.userName = B.userName
相关问题