永发信息网

【case when】mysql的casewhen语句转oraclewhere子句条件如下:where....

答案:2  悬赏:60  手机版
解决时间 2021-02-23 21:43
  • 提问者网友:人傍凄凉立暮秋
  • 2021-02-23 02:19
【case when】mysql的casewhen语句转oraclewhere子句条件如下:where....
最佳答案
  • 五星知识达人网友:七十二街
  • 2021-02-23 02:39
【答案】 oracle也有case when的语法,照办就行,不过用在where条件中,需要有返回值的比较.
  这是根据你提供的语句修改,给你提供一个参考吧:
  where a.xxx = 'asdf' and (
  case
  when (b.i like '%0%') then true
  when (b.i like '%1%') and c.creatorCode = #code# then true
  when (b.i like '%2%') and (d.createDept = #dept# and #flag# = 1) then true
  else false
  end) = true
  这是按照我的业务理解写的
  where a.xxx = 'asdf' and (
  case
  when (b.i like '%0%') then 1
  when (b.i like '%1%') and c.creatorCode = #code# then 2
  when (b.i like '%2%') and (d.createDept = #dept# and #flag# = 1) then 3
  else 4
  end) = 1 -- (根据反回结果来过滤数据)
全部回答
  • 1楼网友:往事隔山水
  • 2021-02-23 02:57
我好好复习下
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯