当前位置:  开发笔记 > 数据库 > 正文

如何在一个语句中更新两列?

如何解决《如何在一个语句中更新两列?》经验,为你挑选了3个好方法。

如何一次更新2列?

我尝试了以下语句,但不起作用:

UPDATE exercises
SET times_answered = times_answered + 1
AND av_answeringTime = av_answeringTime + ( (av_answeringTime / (times_answered) ) + ?) * (times_answered + 1)
WHERE name = ?

Chad Birch.. 53

使用逗号而不是"AND":

UPDATE exercises
SET times_answered = times_answered + 1,
    av_answeringTime = av_answeringTime + ( (av_answeringTime / (times_answered) ) + ?) * (times_answered + 1)
WHERE name = ?


Ayman.. 34

SQL UPDATE语法是:

UPDATE table SET
  column1 = value1,
  column2 = value2
WHERE condition

而不是AND你需要一个逗号



1> Chad Birch..:

使用逗号而不是"AND":

UPDATE exercises
SET times_answered = times_answered + 1,
    av_answeringTime = av_answeringTime + ( (av_answeringTime / (times_answered) ) + ?) * (times_answered + 1)
WHERE name = ?



2> Ayman..:

SQL UPDATE语法是:

UPDATE table SET
  column1 = value1,
  column2 = value2
WHERE condition

而不是AND你需要一个逗号



3> Jhonny D. Ca..:

尝试这样的事......

UPDATE exercises
SET times_answered = times_answered + 1,
av_answeringTime = av_answeringTime + ( (av_answeringTime / (times_answered) ) + ?) * (times_answered + 1)
WHERE name = ?

推荐阅读
pan2502851807
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有