SQL Server加入多个列连接在一起

时间:2014-06-24 21:00:08

标签: sql sql-server

您好我有一个查询,我在尝试将多个列连接成一列,同时加入一个表以将partnumber转换为ID。

我的查询有什么问题?

我收到错误

关键字“JOIN”附近的语法不正确。

但我不知道该如何说出来。

Select ID, Title
from dbo.features
unpivot
(
  Title
  for col in ([Features 1], [Features 2], [Features 3], [Features 4], [Features 5], [Features 6])
) un
order by partnumber, col;
(
JOIN    products.products
ON      Products.Products.PartNumber = dbo.features.PartNumber
)

1 个答案:

答案 0 :(得分:1)

...也许

Select F.ID Feature_ID, F.Title Feature_Title
from dbo.features
INNER JOIN    products.products
  ON Products.Products.PartNumber = dbo.features.PartNumber
unpivot
(
  Title
  for col in ([Features 1], [Features 2], [Features 3], [Features 4], [Features 5], [Features 6])
) un
order by partnumber, col;

但要回答这个问题:我的查询有什么问题?

<强>解答: 您的连接语法错误。