1
我試圖找到最便宜的guitarRig
。吉他鑽具有來自產品的零件(例如,amplifier
,cabinet
,microphone
,guitarType
,guitarStringType
,patchCord
,effectsPedal
)。 產品的購買價格由我的PurchaseInformation
表格決定。MySQL:我如何將多個表聯繫在一起
這裏是我的表:
Table Part:
name
guitarRig references GuitarRig(name)
product references Product(name)
Table Product:
name
part references Part(name)
barcodeNumber
Table PurchaseInformation:
price
product references Product(name)
purchasedFrom references Store(name)
到目前爲止,我有什麼是這樣的:
SELECT guitarRig
FROM Part
WHERE product =
(
SELECT name
FROM Product
WHERE name =
(
SELECT product, MIN(price) as minPrice
FROM PurchaseInformation
GROUP BY minPrice
)
);
我意識到這有許多與此問題(即我想說name
等於兩列,product
和minPrice
),但我不能爲我的生活找出如何得到我正在尋找的。