我使用SELECT COUNT(*)检查我的WHERE语句并获得了正确的更新次数,但是当我尝试UPDATE时,我在第3行遇到语法错误。
UPDATE scans AS s
SET s.sbjnum = d.sbjnum
JOIN details AS d on d.name = s.name
WHERE s.sbjnum =''
答案 0 :(得分:1)
您必须拥有FROM
才能拥有JOIN
UPDATE scans
SET sbjnum = d.sbjnum
FROM scans s
JOIN details AS d ON d.name = s.name
WHERE s.sbjnum =''
根据MySQL手册,您可以这样写:
UPDATE scans AS s
JOIN details AS d ON d.name = s.name
SET sbjnum = d.sbjnum
WHERE s.sbjnum =''