我尝试通过调用该表上的条件来更新我的表,并收到错误。
update grade G
set G.`score` = G.`score` + 5
where G.`snum` IN (select G1.`snum` from grade G1 where G1.`cname` ='Database Systems' And G1.`score` <> 'NULL' AND G1.`score` <= 95));
我不知道为什么它会给我语法错误 因为下面的行给了我 2 个满足条件的 snum。
where G.`snum` IN (select G1.`snum` from grade G1 where G1.`cname` ='Database Systems' And G1.`score` <> 'NULL' AND G1.`score` <= 95));
最佳答案
如果是同一个表,则不需要子查询,只需直接在 where
上添加条件即可子句:
update grade G
set G.`score` = G.`score` + 5
where G.`cname` ='Database Systems'
And G.`score` <> 'NULL'
AND G.`score` <= 95;
还有这个And G.score <> 'NULL'
这里应该是G.score is not null
相反,可能。除非你有 null 作为字符串
关于mysql - 无法使用该表上的条件调用来更新表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54871831/