我有關於從相同的兩個表中加入多個數據的問題。如何從相同的兩個表中加入多個記錄
第一個表被稱爲imagedata
,它包含以下幾列:
ID|image_blob|mimetype|image_UUID
第二個表稱爲price_history
,它包含以下幾列:
price1|price2|image_name_homePage|image_name_loginPage|image_name_footer
我試圖拉是來自imagedata
表的image_blob
表 其中
imagedata.ID=price_history.image_name_homePage
,並在那裏
imagedata.ID=price_history.image_name_loginPage
,並在那裏
imagedata.ID=price_history.image_name_footer
基本上,我想實現的是,將顯示從imagedata
其中imagedata.id
等於price_history."price_history.image_*"
所有圖像斑點結果我似乎無法做到。我得到一個空的結果。 這裏是我當前的查詢:
SELECT
imagedata.`image_blob` as "blobA",
imagedata.`image_blob` as "blobB",
imagedata.`image_blob` as "blobC",
FROM
imagedata
JOIN price_history AS price_historyA ON imagedata.`ID`=price_historyA.`image_name_homePage`
JOIN price_history AS price_historyB ON imagedata.`ID`=price_historyB.`image_name_loginPage`
JOIN price_history AS price_historyC ON imagedata.`ID`=price_historyB.`image_name_footer`
可以顯示示例數據和預期結果,或者更好地提供sqlfiddle。 – Jens
'price_historyC'的JOIN指'price_historyB',這可能是您的問題。 – Jim