MySQL equivalent of DECODE function in Oracle

后端 未结 8 2349
南方客
南方客 2020-11-29 09:26

I am trying to find an equivalent of DECODE function in MySQL. It works like this:

Select Name, DECODE(Age,
       13,\'Thirteen\',14,\'Fourteen\',15,\'Fifte         


        
8条回答
  •  借酒劲吻你
    2020-11-29 09:35

    Select Name, 
    case 
      when Age = 13 then 'Thirteen'
      when Age = 14 then 'Fourteen'
      when Age = 15 then 'Fifteen'
      when Age = 16 then 'Sixteen'
      when Age = 17 then 'Seventeen'
      when Age = 18 then 'Eighteen'
      when Age = 19 then 'Nineteen'
      else 'Adult'
    end as AgeBracket
    FROM Person
    

提交回复
热议问题