2

我的数据库中有一个表选项,我有列“question_id”。在我的表中,我有大约 1000 条记录。

我在表中对列“question_id”的要求是什么,无论我有 1 我想用 131 和 2 用 132 来补充,3 用 133 等等,直到 1000 条记录。

我试图做这样的事情..

UPDATE `dta`.`options` SET `question_id` = '132' WHERE `id` > 435 AND `question_id` = 1

搜索某种函数或运算符。请帮我 !!

例子 :-

UPDATE `dta`.`questions` SET `quiz_id` = '7' WHERE `id` > 131 AND `quiz_id` = 1

UPDATE `dta`.`questions` SET `quiz_id` = '8' WHERE `id` > 131 AND `quiz_id` = 2

UPDATE `dta`.`questions` SET `quiz_id` = '9' WHERE `id` > 131 AND `quiz_id` = 3

UPDATE `dta`.`questions` SET `quiz_id` = '10' WHERE `id` > 131 AND `quiz_id` = 4

UPDATE `dta`.`questions` SET `quiz_id` = '11' WHERE `id` > 131 AND `quiz_id` = 5

UPDATE `dta`.`questions` SET `quiz_id` = '12' WHERE `id` > 131 AND `quiz_id` = 6
4

2 回答 2

1
UPDATE dta.options 
SET question_id = question_id + 130
order by question_id
limit 1000
于 2013-08-06T11:02:25.120 回答
1

你能做到吗

UPDATE `dta`.`options` SET `question_id` = question_id + 130 WHERE `id` > 435
于 2013-08-06T11:03:20.467 回答