userID | name
1 | John
2 | Mary
3 | Jack
項目表(用戶將選擇和存儲到MySQL
itemID | name | item
1 | Mary | pants, jeans
1 | John | jacket, shirt
1 | Jack | jacket, shirt
描述表(檢索基於哪些用戶的說明選擇項目)
descID | item | descOne | descTwo
1 | jacket, shirt | Nice! | Great
1 | pants, jeans | good | Nice
1 | dress, jeans | Nice! | Great
如果我想檢索Mary的值,我應該選擇什麼sql語句?
目前我有這個 - >
SELECT
d.item,
d.descOne,
d.descTwo,
i.name , d.item
FROM description d
INNER JOIN items i
WHERE d.item = i.item ON;
如果定義外鍵,而不是項目和用戶名的外鍵 –