decode()oracle函数在mysql中转化

decode()是oracle数据库的一种函数,类似于java中if三目运算,在mysql中是没有decode()函数的,但mysql中可以用if语句来代替,长话短说,举个例子就很明白了:

我们首先看一下java中三目运算:

     int i=(4>3)?4:3;

     其中    (4>3)?4:3   java if三目运算

decode()在oracle 表示:

      decode(node_count ,null, 0, 1)

转换成mysql   语句 if:

      if(node_count=null,0,1)

  转换成mysql  case when 语句:

    (case when node_count=null then 0 else 1 end)

可以的话,点个赞 谢谢

猜你喜欢

转载自blog.csdn.net/qq_37453201/article/details/86303877