语法错误“从附近的”使用UPDATE时加入MySQL的?(Syntax error “near FR

2019-09-16 15:46发布

UPDATE bestall SET view = t1.v, rawview = t1.rv 

FROM bestall INNER JOIN beststat as t1

ON bestall.bestid = t1.bestid

此查询给附近的语法错误

 'FROM bestall INNER JOIN beststat as t1 ON bestall.bestid = t1.bestid' at line 3

任何原因?

Answer 1:

这不是有效的MySQL语法。 这 MS SQL Server中有效,但是。 对于MySQL,使用方法:

UPDATE 
  bestall
  JOIN beststat AS t1 ON bestall.bestid = t1.bestid 
SET view = t1.v, rawview = t1.rv

MySQL的需要更新的表来的前SET子句。 见MySQL的UPDATE语法参考的全部细节。



Answer 2:

试着这样说:

UPDATE bestall INNER JOIN beststat as t1
ON bestall.bestid = t1.bestid SET view = t1.v, rawview = t1.rv 


文章来源: Syntax error “near FROM” when using UPDATE with JOIN in MySQL?