MySQL multiple condition judgment example

Source: Internet
Author: User

How does one determine multiple MySQL conditions? The following is an example of how to use MySQL to determine multiple conditions.

 
 
  1. use industry_finance;   
  2. DELIMITER //   
  3. drop procedure if exists updateCursor //   
  4. CREATE PROCEDURE updateCursor()   
  5. BEGIN   
  6. declare id varchar(20);   
  7. declare month varchar(20);   
  8. declare season varchar(20);   
  9. declare cur1 CURSOR FOR SELECT ID_,month_ FROM t_industry_finance_instance;   
  10. OPEN cur1;   
  11. FETCH cur1 INTO id,month;   
  12. WHILE (id is not null ) DO   
  13. if(month='01'||month='02'||month='03') THEN set season='1';   
  14. end if;   
  15. if(month='04'||month='05'||month='06') THEN set season='2';   
  16. end if;   
  17. if(month='07'||month='08'||month='09') THEN set season='3';   
  18. end if;   
  19. if(month='10'||month='11'||month='12') THEN set season='4';   
  20. end if;   
  21. update t_industry_finance_instance set seasonseason_=season where ID_=id;   
  22. FETCH cur1 INTO id,month;   
  23. END WHILE;   
  24. CLOSE cur1;   
  25. END;//   
  26. DELIMITER ;   
  27. call updateCursor();  

Replace string with the MySQL replace Function

Usage of MySQL string connection functions

Mysql query case

How to Implement MySQL full-text Query

Example of the number of MySQL query results

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.