mySQL语法中的存储过程及if语句的使用简例

 1 create procedure gh()  #注意各个地方的分号!此代码应先运行除掉最后一句的部分,然后运行call gh显示已经存储的结果
 2 BEGIN
 3 declare c_no int;  #声明数据类型的方法
 4 
 5 select count(*) into c_no    # 将一个结果存入一个变量
 6 from jyb 
 7 where jszh in(
 8 select jszh
 9 from dzb
10 where dw = '经济系');
11 
12 if c_no = 0 then    #if......then......else.....end if
13 select xm as 姓名,dw as 所在单位,zc as 职称
14 from dzb
15 where dw = '经济系' and
16 not exists (
17 select *
18 from jyb,dzb
19 where dzb.jszh = jyb.jszh and dw = '经济系');
20 
21 else 
22 select '此系还有人没有还书'; #此处select相当于print
23 
24 END if;
25 END
26 
27 
28 call gh;

 

 

Python3 从入门到开车

 

posted @ 2017-03-27 18:08  覆手为云p  阅读(22507)  评论(0编辑  收藏  举报
停止精灵球