【发布时间】:2015-01-05 09:56:11
【问题描述】:
我有两张桌子
table1
productName category S_Id value
p1 cat1 1 year
p1 cat1 2 test1
p1 cat1 3 test2
table2
S_Id specificatio
1 year
2 test1
3 test2
而我的需要是像这样绑定网格视图
productName category year test1 test2
p1 cat1 1 2 3
我试过了
select P.productName,P.category,S.specification from table1 P inner join table2 S on(P.S_Id=S.S_Id)
但它显示的结果喜欢
productName category specification
p1 cat1 year
p1 cat1 test1
p1 cat1 test2
任何人都可以帮助如何实现这一点。在此先感谢
【问题讨论】:
-
您需要对数据进行透视。
标签: c# sql sql-server sql-server-2008