[英]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.