2016-12-26 39 views
-2

你好,我有搜索太多,我檢查了我的查詢字一個字,但我不能修復這個錯誤我有錯誤,當使用內部mysql中有3個表加入

我的查詢:

SELECT color_table.color, size_table.size, size_table.length, size_table.sum, image_table.image_url, manto_table.name, manto_table.description, manto_table.price_sale, manto_table.price_coop, 
manto_table.price_single FROM size_table INNER JOIN 
         color_table ON size_table.color_id = color_table.id INNER JOIN 
         manto_table INNER JOIN 
         image_table ON manto_table.id = image_table.manto_id ON size_table.manto_id = manto_table.id; 

錯誤:

類型:PDOException
代碼:42000
消息:SQLSTATE [42000]:語法錯誤或訪問衝突:1064您有一封你的SQL語法中的錯誤;檢查的行對應於你的MySQL服務器版本使用附近的正確語法「ON size_table.manto_id = manto_table.id」手動5

+0

INNER JOIN manto_table ** ** ON缺少 –

+0

「的」 最後加盟之前忘了? – Eugen

+0

該消息似乎不言自明 – Strawberry

回答

0
SELECT color_table.color, 
     size_table.size, 
     size_table.length, 
     size_table.sum, 
     image_table.image_url, 
     manto_table.NAME, 
     manto_table.description, 
     manto_table.price_sale, 
     manto_table.price_coop, 
     manto_table.price_single 
FROM size_table 
     LEFT JOIN color_table AS color_table 
       ON size_table.color_id = color_table.id 
     LEFT JOIN manto_table AS manto_table 
       ON manto_table.id = image_table.manto_id 
     LEFT JOIN image_table AS image_table 
       ON size_table.manto_id = manto_table.id; 
0

修改這樣的:

SELECT color_table.color, size_table.size, size_table.length, size_table.sum, image_table.image_url, manto_table.name, manto_table.description, manto_table.price_sale, manto_table.price_coop, 
manto_table.price_single 
FROM size_table 
INNER JOIN color_table ON size_table.color_id = color_table.id 
INNER JOIN manto_table ON manto_table.id = image_table.manto_id 
INNER JOIN image_table ON size_table.manto_id = manto_table.id; 
0

重組織你的句子:

SELECT color_table.color, size_table.size, size_table.length, size_table.sum, image_table.image_url, 
     manto_table.name, manto_table.description, manto_table.price_sale, manto_table.price_coop, manto_table.price_single 
FROM size_table 
    INNER JOIN manto_table ON size_table.manto_id = manto_table.id 
    INNER JOIN image_table ON manto_table.id = image_table.manto_id 
    INNER JOIN color_table ON size_table.color_id = color_table.id ;