三个表UPDATE和JOIN导致错误1064

时间:2016-11-12 10:44:57

标签: mysql sql

我正在尝试执行以下代码:

UPDATE 
    CustomerShowing
SET 
    CustomerShowing.rate = 5
FROM 
    CustomerShowing
INNER JOIN 
    Showing
ON 
    CustomerShowing.showid = Showing.showid
INNER JOIN 
    Movie
ON 
    Showing.movieid = Movie.movieid
WHERE 
    Movie.name='Batman';

但是我收到以下错误:

  

第86行的错误1064(42000):您的SQL语法出错;   检查与您的MySQL服务器版本对应的手册   正确的语法在'FROM CustomerShowing INNER JOIN显示ON附近使用   CustomerShowing.ShowingID =显示'第3行

我该如何解决这个问题?我使用的是MySQL版本5.5.53

1 个答案:

答案 0 :(得分:2)

MySQL使用与SQL-Server不同的语法。

 UPDATE CustomerShowing
 INNER JOIN Showing ON CustomerShowing.showid = Showing.showid
 INNER JOIN Movie ON Showing.movieid = Movie.movieid
 SET CustomerShowing.rate = 5
 WHERE Movie.name='Batman';