#1064 SQL语法;

时间:2013-12-09 16:44:47

标签: mysql sql

有谁能看到我做错了什么,在这里? 当我在没有“CREATE VIEW [Bookings_View] AS”的情况下运行语句时 它工作正常并带回所需的东西。

 CREATE VIEW [Bookings_View] AS
 SELECT Customer.First_Name,Customer.Last_Name,Vehicles.Make,
 Vehicles.Model,Bookings.Pick_Up_Date, Bookings.Return_Date,Bookings.Booking_Id
 FROM Bookings
 INNER JOIN Vehicles ON Bookings.Vehicle_Id = Vehicles.Vehicle_Id
 JOIN Customer ON Bookings.Customer_Id = Customer.Customer_Id
  

错误:#1064 - 您的SQL语法出错;查看与您的MySQL服务器版本对应的手册,以便在'[Bookings_View] AS SELECT Customer.First_Name,Customer.Last_Name,Vehicles.Make,'at line 1

附近使用正确的语法

谢谢。

4 个答案:

答案 0 :(得分:1)

不要使用括号进行转义。不使用任何东西或backtiks(``)。

CREATE VIEW Bookings_View
CREATE VIEW `Bookings_View`

答案 1 :(得分:0)

MySQL使用反引号(`)而不是括号([])。你的sql语句应该说明

CREATE VIEW `Bookings_View` AS
SELECT Customer.First_Name,Customer.Last_Name,Vehicles.Make,
Vehicles.Model,Bookings.Pick_Up_Date, Bookings.Return_Date,Bookings.Booking_Id
FROM Bookings
INNER JOIN Vehicles ON Bookings.Vehicle_Id = Vehicles.Vehicle_Id
JOIN Customer ON Bookings.Customer_Id = Customer.Customer_Id

答案 2 :(得分:0)

您应该使用反引号而不是[]

使用,

CREATE VIEW `Bookings_View` AS

而不是

CREATE VIEW [Bookings_View] AS

答案 3 :(得分:0)

试试这个......(使用反引号转义字符)

CREATE VIEW `Bookings_View` AS
SELECT Customer.First_Name,Customer.Last_Name,Vehicles.Make,
Vehicles.Model,Bookings.Pick_Up_Date, Bookings.Return_Date,Bookings.Booking_Id
FROM Bookings
INNER JOIN Vehicles ON Bookings.Vehicle_Id = Vehicles.Vehicle_Id
JOIN Customer ON Bookings.Customer_Id = Customer.Customer_Id