MySQL Query出错(1064)

时间:2015-12-08 19:59:56

标签: mysql

好吧,我正在尝试使用内连接加入我的两个表。这是我正在运行的查询:

select * from online_booking.Booking_ID, movie_schedule.Movie_ID, online_booking.Customer_Name, online_booking.Customer_Cell_No, online_booking.Quantity_Of_Tickets 
from movie_schedule
inner join online_booking
on movie_schedule.Movie_ID=online_booking.Movie_ID

这是我的表结构:

CREATE TABLE IF NOT EXISTS `movie_schedule` (
  `Movie_ID` int(20) NOT NULL AUTO_INCREMENT,
  `Movie_Name` varchar(100) NOT NULL,
  `Movie_Date` varchar(20) NOT NULL,
  `Show_Time` varchar(100) NOT NULL,
  `Movie_Cost` int(20) NOT NULL,
  `Tickets_Availability` varchar(20) NOT NULL,
  PRIMARY KEY (`Movie_ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

CREATE TABLE IF NOT EXISTS `online_booking` (
  `Booking_ID` int(15) NOT NULL AUTO_INCREMENT,
  `Quantity_Of_Tickets` int(10) NOT NULL,
  `Customer_Name` varchar(20) NOT NULL,
  `Customer_Cell_No` varchar(20) NOT NULL,
  `Movie_ID` int(15) NOT NULL,
  PRIMARY KEY (`Booking_ID`),
  KEY `Movie_ID` (`Movie_ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=114 ;

ALTER TABLE `online_booking`
  ADD CONSTRAINT `online_booking_ibfk_1` FOREIGN KEY (`Movie_ID`) REFERENCES `movie_schedule` (`Movie_ID`);

令我惊讶的是,我收到以下错误:

错误代码:1064 您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在movie_schedule附近使用正确的语法 内部联接online_booking on movie_schedule.Movie_ID = online _'在第2行 (0毫秒)

我错过了什么吗?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

您已将字段列表放在

之后

请将select * from <field list>更改为select <field list> from,如下所示:

select online_booking.Booking_ID, movie_schedule.Movie_ID, online_booking.Customer_Name, online_booking.Customer_Cell_No, online_booking.Quantity_Of_Tickets 
from movie_schedule
inner join online_booking
on movie_schedule.Movie_ID=online_booking.Movie_ID