我有这样的查询:
UPDATE `portal_dyslektyczny`.`questions` AS `Question` SET `Question`.`order` = `Question`.`order` - (`Question`.`order` - 3) + 1 WHERE `Question`.`order` > 3 AND `Question`.`question_group_id` = 1;
即使所有行都有升序
+----+-------+-------------------+
| id | order | question_group_id |
+----+-------+-------------------+
| 74 | 6 | 1 |
| 75 | 7 | 1 |
| 76 | 8 | 1 |
+----+-------+-------------------+
但是当我运行查询表时像这样结束
+----+-------+-------------------+
| id | order | question_group_id |
+----+-------+-------------------+
| 74 | 4 | 1 |
| 75 | 4 | 1 |
| 76 | 4 | 1 |
+----+-------+-------------------+
当我得到它的每一行值变化应该是这样的
ID: 74
`Question`.`order` = 6 - ( 6 - 3) + 1;
ID: 75
`Question`.`order` = 7 - ( 7 - 3) + 1;
很快。
但事实并非如此。看起来它只从第一行获取值。有谁知道为什么?