A brief example of the use of stored procedures and if statements in MySQL syntax

Source: Internet
Author: User

1 Create proceduregh () #注意各个地方的分号! This code should run the section that removes the last sentence, and then run call GH to display the results that have been stored2 BEGIN3 DeclareC_noint; #声明数据类型的方法4 5 Select Count(*) intoC_no # Depositing a result into a variable6  fromJYB7 whereJszhinch(8 SelectJszh9  fromDzbTen whereDw= 'Department of Economics'); One  A ifC_no= 0  Then#if...... Then......Else.....End if - SelectXm asName, DW asUnit, ZC asJob Title -  fromDzb the whereDw= 'Department of Economics'  and -  not exists ( - Select * -  fromJyb,dzb + whereDzb.jszh=Jyb.jszh andDw= 'Department of Economics'); -  + Else  A Select 'There are people in this department who haven't returned.'; #此处select相当于print at  - END if; - END -  -  -Call GH;

A brief example of the use of stored procedures and if statements in MySQL syntax

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.