语法错误mysql(按长度排序)

时间:2013-04-26 02:26:16

标签: mysql phpmyadmin

我在这个特殊声明中遇到语法错误,我已经完成了声明并检查了错误,似乎无法找到任何错误,也许是一副新鲜的眼睛可能会看到一些东西。

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 LENGTH(Purchase_Order.Airline_Carrier_Code)附近使用正确的语法,在第1行* *

2 个答案:

答案 0 :(得分: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; 

答案 1 :(得分:2)

INNER JOIN Aircraft_Purchased.Aircraft_ID = Aircraft.Aircraft_ID ORDER BY

INNER JOIN table name和ON部分。