好吧,我有2個表格。一張表格爲Product List
,另一張表格爲Orders
。在我的Table1中會有幾個相同的ProductID
,因爲每個ProductID
都有幾個部分(IE:7的第1部分)。MySQL查詢 - 獲得沒有購買單個產品ID的所有部分的客戶ID
PartNumber
將是一個數字。如何設計我的查詢以找到所有已購買部件編號的客戶,而不是單個產品編號的所有部件編號?
我只是學習MySQL的基礎知識,所以任何幫助將不勝感激!
表1 - 產品列表
UniqueIDKey
Product ID
PartNumber
表2 - 訂單
UniqueIDKey
Product ID Ordered
PartNumber Ordered
Customer ID
所以訂單可能是這樣的:
UniqueIDKey: 77
Product ID Ordered: 1001
PartNumber Ordered: 3
Customer ID: 2000001
而且,我的Table1 - Product List
的幾行可能看起來像這個:
UniqueIDKey Product ID PartNumber
77 1001 1
78 1001 2
79 1001 3
什麼是你的策略是什麼?我的意思是你到目前爲止所嘗試過的?請隨時分享。 – 1000111