问题
UPDATE bestall SET view = t1.v, rawview = t1.rv
FROM bestall INNER JOIN beststat as t1
ON bestall.bestid = t1.bestid
this query gives syntax error near
'FROM bestall INNER JOIN beststat as t1 ON bestall.bestid = t1.bestid' at line 3
any reasons?
回答1:
That isn't valid MySQL syntax. It is valid in MS SQL Server, however. For MySQL, use:
UPDATE
bestall
JOIN beststat AS t1 ON bestall.bestid = t1.bestid
SET view = t1.v, rawview = t1.rv
MySQL requires the update tables to come before the SET
clause. See the MySQL UPDATE syntax reference for full details.
回答2:
Try it this way:
UPDATE bestall INNER JOIN beststat as t1
ON bestall.bestid = t1.bestid SET view = t1.v, rawview = t1.rv
来源:https://stackoverflow.com/questions/10262300/syntax-error-near-from-when-using-update-with-join-in-mysql