在 access 2016 中,我有 3 個表:
Tb產品
productId | descriptionProduct
1 | PC1
2 | PC2
Tb特性
CaracId | DescriptionCarac
1 | Motherboard size
2 | Processor
3 | Color
4 | Size
Tb特性產品
productId | CaracId | Value
1 | 1 | ATX
1 | 2 | i5
1 | 3 | Black
1 | 4 | Big tower
2 | 1 | MiniITX
2 | 2 | i7
2 | 3 | Blue
2 | 4 | Big tower
我想要顯示的內容:
Product | Motherboard size | Processor | Color | Size
PC1 | ATX | i5 | Black | Big tower
PC2 | MiniITX | i7 | Blue | Big tower
我嘗試查詢以獲取特性串列,但我不知道如何將它們放在另一個列中,也不知道如何鏈接第三個表中的資訊......有什么想法嗎?
我也嘗試使用 min(value) 和 max(value),但問題是我有兩個以上的特征。
uj5u.com熱心網友回復:
看起來像基本的 JOIN 和 CROSSTAB。
TRANSFORM First(TbCaracteristicsProducts.Value) AS FV
SELECT TbProducts.descriptionProduct
FROM (TbCaracteristics INNER JOIN TbCaracteristicsProducts ON TbCaracteristics.CaracID = TbCaracteristicsProducts.CaracId)
INNER JOIN TbProducts ON TbCaracteristicsProducts.ProductId = TbProducts.ProductID
GROUP BY TbProducts.descriptionProduct
PIVOT TbCaracteristics.DescriptionCarac;
順便說一句,拼寫錯誤的“caracteristic”——缺少“h”。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/535577.html
