0

我使用 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 =''
4

1 回答 1

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 =''
于 2012-04-04T18:30:59.567 回答