[英]How can I join the same table to bring me one result?
我想创建一个查询而不是给我带来以下结果:
Product | attibutname | attibutname | Value |
5547 | Lacoste | Enable / Disable | 20
5548 | Vans | Enable / Disable | 10
该表如下所示:
id | Product | Attributname | value
1 | 5547 | Brand | Lacoste
2 | 5547 | Woman /Mens | 1
3 | 5547 | Enable / Disable | 20
4 | 5548 | Brand | Vans
2 | 5548 | Woman /Mens | 0
3 | 5548 | Enable / Disable | 10
`
类似于下面的内容是您将如何将表连接到自身(根据您提供的内容进行假设)。 您需要为每个副本添加别名,以便了解您是在谈论品牌还是表的不同属性行。
Select b.Product, b.value [Attributename1], g.Attributename, g.value
from myItemTable b
join myItemTable g ON g.id = b.id
Where b.Attributename = 'Brand'
and g.Attributename = 'Enable / Disable'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.