MySQL equivalent of DECODE function in Oracle

后端 未结 8 2361
南方客
南方客 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:42

    You can use IF() where in Oracle you would have used DECODE().

    mysql> select if(emp_id=1,'X','Y') as test, emp_id from emps; 
    

提交回复
热议问题