SQL:一次更新4行的每个值

时间:2017-04-10 20:00:37

标签: sql

嗨,所以目前我的桌子看起来像这样: enter image description here

我想要的是一个更新列的SQL查询:hplayer,aplayer,g1h,g1a,g2h,g2a,g3h,g3a,g4h,g4a
例如,对于将matchid设置为“3”的每一行。
这可能吗?我该怎么做?

3 个答案:

答案 0 :(得分:0)

更新语法:

UPDATE table-name 
SET column-name = value, column-name = value, ...
WHERE condition

尝试这样的事情:(将?改为你想要的值)

UPDATE TABLE
SET player = ?,
    aplayer = ?,
    g1h = ?, 
    g1a = ?,
    g2h = ?,
    g2a = ?,
    g3h = ?,
    g3a = ?,
    g4h = ?,
    g4a = ?
WHERE matchid = 3

答案 1 :(得分:0)

update table_name 
set hplayer=1,
    aplayer=1,
    g1=1,
    g1a=1,
    g2h=1,
    g2a=1,
    g3h=1,
    g3a=1,
    g4h=1,
    g4a=1 
where matchid=3

答案 2 :(得分:0)

来自w3schools SQL Tutorial的示例:

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

在你的情况下:

UPDATE table_name
  SET hplayer="11",
  aplayer="22",
  g1h="33",
  g1a="44",
  g2h="55",
  g2a="66",
  g3h="77",
  g3a="88",
  g4h="99",
  g4a="00" 
  WHERE matchid = "3";

同时尝试searching sql update