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

时间:2023-03-09 17:29:34
mySQL语法中的存储过程及if语句的使用简例
 create procedure gh()  #注意各个地方的分号!此代码应先运行除掉最后一句的部分,然后运行call gh显示已经存储的结果
BEGIN
declare c_no int; #声明数据类型的方法 select count(*) into c_no # 将一个结果存入一个变量
from jyb
where jszh in(
select jszh
from dzb
where dw = '经济系'); if c_no = 0 then    #if......then......else.....end if
select xm as 姓名,dw as 所在单位,zc as 职称
from dzb
where dw = '经济系' and
not exists (
select *
from jyb,dzb
where dzb.jszh = jyb.jszh and dw = '经济系'); else
select '此系还有人没有还书'; #此处select相当于print END if;
END call gh;

Python3 从入门到开车