Home > database >  For a great god, the update cycle
For a great god, the update cycle

Time:09-18

Fields in table a, b is int, now will b <10 value until=10 + 1, the great god, how to do this?

CodePudding user response:

Udpate t set b=b + 1 where b & lt; 10;

Loop execution

CodePudding user response:

If the current is less than 10 b set value, the largest is equal to 10, execute the following statements, do a can, do not need to cycle,
UPDATE the SET b=b + (SELECT tc FROM (SELECT 10 - MAX (a.) c FROM a WHERE clause a. & lt; 10) t) WHERE a. & lt; 10;
If the current is less than 10 b set value, all equal to 10, execute the following statements, do a can, do not need to cycle,
UPDATE the SET b=10 WHERE a. & lt; 10;

CodePudding user response:

Table A add A list of C, C has A value of b + 1, updated based on C b, conditions to satisfy C & lt;=10, no validation, for your reference
  • Related