我尝试通过调用该表上的条件来更新表,并得到错误消息。
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个满足条件的编号。
where G.`snum` IN (select G1.`snum` from grade G1 where G1.`cname` ='Database Systems' And G1.`score` <> 'NULL' AND G1.`score` <= 95));
答案 0 :(得分:0)
如果是同一张表,则不需要子查询,只需将条件直接添加到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作为字符串
答案 1 :(得分:0)
最后有2个右括号,请删除1个括号