mysql 預存程序case語句文法與執行個體教程

來源:互聯網
上載者:User

接著我們要講的是關於mysql教程 預存程序case語句文法與執行個體教程哦,首頁我們來看看case語句的簡單說明,再以執行個體說明case的具體用法。

case語句。

case語句比起if要複雜了一些,它可以構造更複雜的條件。

Case condtion

          WHEN whenvalue THEN statlist

        [when value then statmentlist]

         [else statmentlist]

end case

or:

case

      when scontion then stlist

    [when sconteiont then statlist]

   [else statlst]

end case

在編程中if的大多語句可以用case 來完成,當然了case的所有作法if都能完成,下面我們來看一個case的執行個體教程吧。

case

      when iid=2 then

           set @x=@x1+dcount;

        else

           set @x2 = @x2+ dcount;

   end case;

或者

case id

   when 2 then

  @x1 = @x1 + 5;

else

  @x111cn.net = @x111cn.net+ 'www.111cn.net';

end case;

好了關於case文法與執行個體用法我們都舉了一個執行個體說明了,如果不明白可以查看相關文章。

本站原創文章轉載的朋友麻煩加上本站地址,原創不容易謝謝,

轉載地址 www.111cn.net/database/database.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.