while(0=0)
begin
select @n =COUNT(*) from tests where score<200
if(@n>0)
update tests set score=score+10 where score<100
else
break
end
select * from tests
è¿å¥è¯æ¬èº«æ²¡æä»ä¹é®é¢ï¼å¯å®é
æ
åµå®¹æé ææ»å¾ªç¯ï¼æ¯å¦æä¸æ¡æ°æ®çscore=99ï¼å¾ªç¯æ§è¡ä¸æ¬¡åï¼æ¤æ¡è®°å½çscore=109ï¼è¿æ¡æ°¸è¿é½ä¼æ»¡è¶³select @n =COUNT(*) from tests where score<200 使@n>0ï¼ä½å满足ä¸äºupdate tests set score=score+10 where score<100
è¿å¥è¯ä¸çæ¡ä»¶ï¼æ以æ¤æ¡è®°å½æ°¸è¿é½ä¼è¢«æ§è¡if @n>0 è¿ä¸ªè¯å¥åï¼ä¸ä¼æ§è¡elseä¸çé¨åï¼ç±æ¤é ææ»å¾ªç¯
温馨提示:内容为网友见解,仅供参考