下面sql语句是MySQL写法
select count(*) from sys_dept where status = 0 and del_flag = '0' and
find_in_set(#{deptId}, ancestors)
find_in_set 函数的功能就是查询前一个字符串在后一个字符串中是否存在,
如果存在就返回空,如果存在就返回,前一个字符串在后一个字符串所在的位置
在Oracle环境下运行则会出现这样的错误
ORA-00920:无效的关系运算符
Oracle中的instr函数跟find_in_set函数的功能类似,用之替换
在Oracle中的正确写法为
select count(*) from sys_dept where status = 0 and del_flag = '0'
and instr(#{deptId}, ancestors)>0
这篇博客探讨了在MySQL和Oracle数据库中处理字符串查询的不同之处,特别是`find_in_set`函数在MySQL中的使用及其在Oracle中等效的`instr`函数。当从MySQL迁移到Oracle环境时,由于不支持`find_in_set`,需要使用`instr`函数进行替代。文章通过示例展示了如何在Oracle SQL查询中正确使用`instr`来实现相同的功能。
2119

被折叠的 条评论
为什么被折叠?



