首页 热点专区 义务教育 高等教育 出国留学 考研考公

mysql的case when语句转oracle

发布网友

我来回答

3个回答

热心网友

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 -- (根据反回结果来过滤数据)

热心网友

- -! 不知道你说啥 d.createDept = #dept# and #flag# = 1 能对么。。。追问##是ibatis中的占位符....我都说过sql改过,但意思还是明白的,光在意这些小细节,整体意思搞懂了么?

热心网友

mysql不熟

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com