2013-04-26 55 views
-1

我得到這個特定的語句的語法錯誤,我已經真正的聲明和檢查錯誤,似乎無法找到任何,也許一雙新鮮的眼睛可能會看到的東西。語法錯誤mysql(按長度排序)

SELECT Purchase_Order.Airline_Carrier_Code, 
     Aircraft_Purchased.*, 
     Aircraft.Unit_Price * Aircraft_Purchased.Quantity as Total_Cost 
    FROM Aircraft_Purchased 
INNER JOIN Purchase_Order ON Aircraft_Purchased.Order_Number = Purchase_Order.Order_Number 
    INNER JOIN Aircraft_Purchased.Aircraft_ID = Aircraft.Aircraft_ID 
ORDER BY (Purchase_Order.Airline_Carrier_Code), Purchase_Order.Airline_Carrier_Code; 

錯誤代碼我收到低於

1064 - 你在你的SQL語法錯誤;檢查對應於你的MySQL服務器版本使用附近的「.Aircraft_ID ORDER BY長度(Purchase_Order.Airline_Carrier_Code),Purchase_Orde」在行權語法手冊* 1 *

回答

3

你錯過了Aircraft第二INNER JOIN後表參考:

SELECT purchase_order.airline_carrier_code, 
     aircraft_purchased.*, 
     aircraft.unit_price * aircraft_purchased.quantity AS Total_Cost 
FROM aircraft_purchased 
     INNER JOIN purchase_order 
       ON aircraft_purchased.order_number = purchase_order.order_number 
     INNER JOIN aircraft <--- here 
       ON aircraft_purchased.aircraft_id = aircraft.aircraft_id 
ORDER BY purchase_order.airline_carrier_code; 
+0

謝謝,我知道這是簡單的事情 – tarantino 2013-04-26 02:32:22

2

INNER JOIN Aircraft_Purchased.Aircraft_ID = Aircraft.Aircraft_ID ORDER BY

INNER JOIN table name,和ON部分。