我的桌子下面有行:
id | s1 | s2 | s3 | s4 | s5 |
---------------------------------------
1 | 6 | 2 | null | null | null |
---------------------------------------
2 | 8 | 1 | null | null | null |
我已经有了这个值,我想将数据添加到 null
的单元格中我的查询是:
UPDATE table1
SET s3 = "some_s3" WHERE id = 1
SET s4 = "some_s4" WHERE id = 1
SET s5 = "some_s5" WHERE id = 1
SET s3 = "some_s3" WHERE id = 2
SET s4 = "some_s4" WHERE id = 2
SET s5 = "some_s5" WHERE id = 2
像这样的东西。但我需要更新千行。
答案 0 :(得分:0)
尝试:
UPDATE table1
SET s3 = "some_s3" WHERE s3 is null
UPDATE table1
SET s4 = "some_s4" WHERE s4 is null
UPDATE table1
SET s5 = "some_s5" WHERE s5 is null
答案 1 :(得分:0)
嗯,最简单的方法是编写PHP脚本,如果你想更新大量数据。
答案 2 :(得分:0)
UPDATE table1 SET s3='some_value1',s4='some_value2',s5='some_value3'
WHERE s3 is null and s4 is null and s5 is null