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 從入門到開車

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM