MySQL equivalent of DECODE function in Oracle

后端 未结 8 2341
南方客
南方客 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条回答
  •  -上瘾入骨i
    2020-11-29 09:46

    you can use if() in place of decode() in mySql as follows This query will print all even id row.

    mysql> select id, name from employee where id in
    -> (select if(id%2=0,id,null) from employee);
    

提交回复
热议问题