我需要减少整数列中的所有值。当其中一个等于0时,它应该停止减小该值并继续减少该列中的所有其他值。 我在Mysql中使用事件计划执行此操作。这有效:
AGE00135039 WeatherRecord@7df8df85
AGE00135039 WeatherRecord@7df8df85
AGE00135039 WeatherRecord@7df8df85
AGE00135039 WeatherRecord@7df8df85
AGE00135039 WeatherRecord@7df8df85
AGE00135039 WeatherRecord@7df8df85
AGE00135039 WeatherRecord@7df8df85
AGE00135039 WeatherRecord@7df8df85
AGE00135039 WeatherRecord@7df8df85
AGE00147704 WeatherRecord@7df8df85
AGE00147704 WeatherRecord@7df8df85
AGE00147704 WeatherRecord@7df8df85
AGE00147704 WeatherRecord@7df8df85
AGE00147704 WeatherRecord@7df8df85
AGE00147704 WeatherRecord@7df8df85
但是如果我添加if语句,它就不起作用
UPDATE dbname.tablename SET money = money - 1;
答案 0 :(得分:0)
您只需将执行限制为包含money
大于零的值的行
UPDATE dbname.tablename SET money = money - 1 WHERE money>0;