0
UPDATE default_weekly_stats s 
INNER JOIN default_profiles p
ON p.user_id = s.user_id
WHERE (default_profiles.opid = 0 OR default_profiles.opid IS NULL) 
    AND s.week = `1`
    AND s.correct_picks = `4`
SET s.rank = 1

这是我的查询,我收到一个错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE (default_profiles.opid = 0 OR default_profiles.opid IS NULL) AND s.week = ' at line 1

语法对我来说是正确的,但显然我遗漏了一些东西。有什么想法吗?

4

2 回答 2

3

WHERE紧随其后 SET

UPDATE default_weekly_stats s 
INNER JOIN default_profiles p ON p.user_id = s.user_id 
SET s.rank = 1
WHERE (default_profiles.opid = 0 OR default_profiles.opid IS NULL) 
AND s.week = 1 
AND s.correct_picks = 4 

正如@Chad 提到的:留下反引号。您可以使用引号,但不需要任何数字分隔符。

于 2013-09-06T15:11:08.543 回答
3

查看更新语法

尝试这个:

UPDATE
  default_weekly_stats s
    INNER JOIN default_profiles p
      ON p.user_id = s.user_id 
SET s.rank = 1
WHERE (default_profiles.opid = 0 OR default_profiles.opid IS NULL)
  AND s.week = `1`
  AND s.correct_picks = `4`
于 2013-09-06T15:12:37.213 回答