mysql的case when语句转oracle
发布网友
发布时间:2022-04-25 04:55
我来回答
共3个回答
热心网友
时间:2022-04-13 00:40
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 -- (根据反回结果来过滤数据)
热心网友
时间:2022-04-13 01:58
- -! 不知道你说啥 d.createDept = #dept# and #flag# = 1 能对么。。。追问##是ibatis中的占位符....我都说过sql改过,但意思还是明白的,光在意这些小细节,整体意思搞懂了么?
热心网友
时间:2022-04-13 03:33
mysql不熟