if 条件判断语句
1.单分支格式
if 判断条件 then
sql语句1
else
sql语句2
end if;
2.多分支 (有多少的if 就需要写多少个end if)
if 条件 THEN
执行sql
else if 条件 THEN
执行sql
else if 条件 THEN
执行sql
.............
else
执行sql
end if
end if
end if
3、往存储过程中加while语句(循环语句)
while 语句的格式:
while 条件 do
执行循环体(sql)
end while;
注意:
什么时候进入循环:当条件成立时,进入循环
什么时候退出循环:当条件不成立时,退出循环
|
|