Transact SQL 查询-Pivot-SQL
我有一个具有结构的表 MySeekCatTable
:
SeekId CatId
J 1<= i<=45
在此表中,每个 SeekId
都有三个 CatId
。 表 MySeekCatTable
引用了两个带有外键的表:
第一个表 SeekTable
以 SeekId
作为主键,如下所示:
SeekId Name
1 John
2 Kelly
第二个表 CatTable
以 CatId
作为主键就像:
CatId Name
1 Cat1
2 Cat2
我的需要是我必须编写一个查询,为每个 SeekId
提供三个 CatId 格式:
SeekId A B C
1 Cat1 Cat2 Cat3
i Cati Catj Catk
I have a table MySeekCatTable
with a structure:
SeekId CatId
J 1<= i<=45
in this table every SeekId
has three CatId
.
The table MySeekCatTable
references two table with foreign keys:
the first table SeekTable
with SeekId
as primary key is like:
SeekId Name
1 John
2 Kelly
the second table CatTable
with CatId
as primary key is like:
CatId Name
1 Cat1
2 Cat2
My need is that I have to write a query that gives for every SeekId
three of its CatId
in the format:
SeekId A B C
1 Cat1 Cat2 Cat3
i Cati Catj Catk
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)