私はテーブルに基づいたクエリを探していました。私はすべてのアイテムを私のショップから持っていました。このテーブルには、次の列が含まれています1つのテーブル内のアイテムについての質問
location: Shop Name
product: Item Number
attributinstance_id: not in use so it always is NULL
Units:count of Items
は、私は他の店であり、それらのどれだけ、結果が同じ行にする必要がありますどの商品を見ることができますクエリを書くのが好き。
例えば:私はそれがすべてのツリー店で入手可能であるか、または利用可能でしたが、私は木のお店の一つでのみ使用可能だったアイテムを検索するとき、彼らはしませんアイテムを走ら
Shop 1 Shop 2 Shop 3
item 1 1 2 5
を表示します。誰かアイデアはありますか?これまで
私の考え:
SELECT Distinct
products.name AS Artikel,
eins.units AS Europa_Center,
zwei.Units AS O_Strasse,
drei.units AS K_Strasse
FROM stockcurrent eins
LEFT JOIN stockcurrent zwei
ON (eins.product = zwei.product
AND eins.location ='0'
AND zwei.location ='a59cb899-27f4-460c-b5df-89a89eaaef75')
LEFT JOIN stockcurrent drei
ON (zwei.product = drei.product
AND zwei.location ='a59cb899-27f4-460c-b5df-89a89eaaef75'
AND drei.location ='3b53adf5-eaee-4a13-b22b-39d50b14e497')
JOIN products
ON products.id = eins.product
JOIN locations
ON locations.id = eins.location
全体のシンクタンクは、POSシステムUnicentas 4.3用です。表は次のようになります。
Location Product atributsinstance_id Units shop_1 item_1 NULL 5 shop_2 item_1 NULL 1 shop_3 item_1 NULL 0 shop_2 item_2 Null 3 shop_1 item_3 Null 2 shop_2 item_3 Null 4 shop_3 item_3 Null 1
テキストとしてポストテーブルとデータ[この記事を読む](http://meta.stackoverflow.com/questions/285551/をどうしても私がアップロードしていない画像のコードの画像285557#285557) –
研究PIVOTのクエリ – Randy