zoukankan      html  css  js  c++  java
  • mysql case when

    下面为您举例说明了三种mysql中case when语句的使用方法,供您参考学习,如果您对mysql中case when语句使用方面感兴趣的话,不妨一看。

    1。

    1. select name,  
    2.  case   
    3.         when birthday<'1981' then 'old'  
    4.         when birthday>'1988' then 'yong'  
    5.         else 'ok' END YORN  
    6. from lee; 

    2。

    1. select NAME,  
    2.  case name  
    3.      when 'sam' then 'yong'  
    4.         when 'lee' then 'handsome'  
    5.         else 'good' end  
    6. from lee; 

    当然了case when语句还可以复合

    3。

    1. select name,birthday,  
    2.  case   
    3.      when birthday>'1983' then 'yong'  
    4.         when name='lee' then 'handsome'  
    5.         else 'just so so ' end  
    6. from lee;  
    7.  

    以上就是mysql中case when语句的使用示例的介绍。

  • 相关阅读:
    限制泛型可用类型
    泛型的常规用法(声明两个类型)
    一个类似于金字塔的图形
    Fibonacci数
    快来秒杀我
    奇偶数分离
    Background
    Financial Management
    HangOver
    Binary String Matching
  • 原文地址:https://www.cnblogs.com/brady-wang/p/6185760.html
Copyright © 2011-2022 走看看