MySQL 高级 - 语法 - if判断
生活随笔
收集整理的這篇文章主要介紹了
MySQL 高级 - 语法 - if判断
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
if條件判斷
?
語法結構 :
if search_condition then statement_list[elseif search_condition then statement_list] ...[else statement_list]end if;需求:
根據定義的身高變量,判定當前身高的所屬的身材類型 180 及以上 ----------> 身材高挑170 - 180 ---------> 標準身材170 以下 ----------> 一般身材示例 :
delimiter $create procedure pro_test6() begindeclare height int default 175; declare description varchar(50);if height >= 180 thenset description = '身材高挑';elseif height >= 170 and height < 180 thenset description = '標準身材';elseset description = '一般身材';end if;select description ; end$delimiter ;調用結果為 :
總結
以上是生活随笔為你收集整理的MySQL 高级 - 语法 - if判断的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 存储过程语法 - 变量
- 下一篇: MySQL 高级 - 输入参数