流程控制
# 流程控制
# case when .. then ... else ... end
# CASE [test] WHEN[val1] THEN [result]...ELSE [default] END
如果test和valN相等,则返回resultN,否则返回default
# if(isnull(), t, f)
如果test是真,返回t;否则返回f
例如: select lession_name, if(isnull(views), 1, 0) from lession_views;
# IFNULL(arg1,arg2)
如果arg1不是空值,返回arg1,否则返回arg2
例如: SELECT lession_name,IFNULL( views,0) + 1000 FROM lession_views;
# NULLIF(arg1,arg2)
如果arg1=arg2返回NULL;否则返回arg1
# if ... then ... end if;
# if ... then ... else ... end if;
# if ... then ... elseif ... then ... else... end if;
# PS: while num < 10 do .... end while;
# PS: repeat ... until num >= 5 end repeat;