sql find_in_set在oracle下的解决方案
- 比如一张表:
- artile (id,type,content);
- type:1表示文艺类,2表示小说类,3表示传记,4表示传说,等等5,6,7,8
- 表数据:
- id type content
- 1 3,1 dfasdfasdf
- 2 1,3,6,8 dfasdf
- 3 6,8,9 add
- 现在要找出3传记类的artile记录
- mysql: select * from artile where find_in_set('3',type);
- oralce 语句实现:
- select * from artile da where instr(','||type||',',',3,')<>0;
- (原理:将1,3,6,8转为 ,1,3,6,8,然后找出 ,3,的位置
- 将3,1转为 ,3,1,然后找出 ,3,的位置
- 则<>0的即为存在,返回记录)
- 用自定义一个find_in_set的oracle function 来解决
- create or replace function find_in_set(arg1 in varchar2,arg2 in varchar)
- return number is Result number;
- begin
- select instr(','||arg2||',' , ','||arg1||',') into Result from dual;
- return(Result);
- end find_in_set;
- 则:select * from artile where find_in_set('3',type)<>0;
- mysql可接受0或其它number做为where 条件,oracle只接受表达式做为where 条件
sql find_in_set在oracle下的解决方案的更多相关文章
- mysql find_in_set在oracle下的解决方案
比如一张表: artile (id,type,content); type:1表示文艺类,2表示小说类,3表示传记,4表示传说,等等5,6,7,8 表数据: id type content 1 3,1 ...
- (014)每日SQL学习:oracle下lag和lead分析函数
/*语法*/ lag(exp_str,offset,defval) over() Lead(exp_str,offset,defval) over() --exp_str要取的列 --offset取偏 ...
- Win7 64位下sql server链接oracle的方法
继上一次mysql同步sql server后,这一次需要将Oracle同步到sql server上来,方案相似,只是在sql server链接oracle的时候费了很多时间. 一.测试环境 本方案实现 ...
- Oracle ->> Oracle下实现SQL Server的TOP + APPLY
今晚很好奇想知道Oracle下有没有APPLY子句?如果有那怎么实现SQL Server下的TOP + APPLY.结果自己写了个例子. with a as ( order by grp_factor ...
- oracle下查询的sql已经超出IIS响应时间
场景: 最近一直发生oracle下查询的sql已经超出IIS响应时间,但是后台DB的SQL查询还未终止,一直在查询.这对DB是造成很大的压力. 解决办法 增加OracleCommand 中的Comma ...
- 【转】SQL Server与Oracle的区别
转自:http://soft.chinabyte.com/database/255/12258255.shtml SQL Server与Oracle的区别 2012-02-10 00:00 中国IT实 ...
- 使用 Oracle GoldenGate 在 Microsoft SQL Server 和 Oracle Database 之间复制事务
使用 Oracle GoldenGate 在 Microsoft SQL Server 和 Oracle Database 之间复制事务 作者:Nikolay Manchev 分步构建一个跨这些平台的 ...
- Oracle Ora 错误解决方案合集
注:本文来源于 < Oracle学习笔记 --- Oracle ORA错误解决方案 > ORA-00001: 违反唯一约束条件 (.)错误说明:当在唯一索引所对应的列上键入重复值时,会触发 ...
- SQL Server,MySQL,Oracle三者的区别
SQL Server,MySQL,Oracle三者的区别 2016-10-14 转自:SQL Server,MySQL,Oracle三者的区别 目录 1 Oracle.Sql Server.MySql ...
随机推荐
- Asynchronous C# server[转]
It hasn't been thoroughly tested, but seems to work OK. This should scale pretty nicely as well. Ori ...
- ORM模型类介绍,
所有的软件开发过程中,都会涉及到对象和关系型数据库,在用户层面和业务逻辑层面,程序员编写代码都是面向对象的,当我们对象的信息发生变化的时候,都需要将对应的信息,传到关系型数据库中.而在此之前,需要我们 ...
- js实现的页面加载完毕之前loading提示效果
页面加载readyState的五种状态 原文如下: 0: (Uninitialized) the send( ) method has not yet been invoked. 1: (Loadin ...
- PAT甲级【2019年3月考题】——A1157 Anniversary【25】
Zhejiang University is about to celebrate her 122th anniversary in 2019. To prepare for the celebrat ...
- BPT(Business Process Testing)
- IE兼容模式下样式分离错乱,求CSS高手
IE正常模式下访问正常 兼容模式右边图片切换区域样式错乱,求CSS高手! 详细参考网址:www.javams.com
- [已解决]报错: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Users/mac/Ana
报错代码: pip3 install gerapy 报错内容: Could not install packages due to an EnvironmentError: [Errno 13] Pe ...
- python基础----以面向对象的思想编写游戏技能系统
1. 许多程序员对面向对象的思想都很了解,并且也能说得头头是道,但是在工作运用中却用的并不顺手. 当然,我也是其中之一. 不过最近我听了我们老师的讲课,对于面向对象的思想有了更深的理解,今天决定用一个 ...
- Ubuntu下配置了ssh,但是连接很慢
ssh登录服务器时总是要停顿等待一下才能连接上,这是因为OpenSSH服务器有一个DNS查找选项UseDNS默认是打开的. UseDNS选项打开状态下,当客户端试图登录OpenSSH服务器时,服务器端 ...
- samba 添加新用户
添加samba新用户需要有root权限 1. 在Linux服务器根目录下(黄色背景部分是需替换部分:换成你自己的用户名) sudo smbpasswd -a username 2. 修改samba配置 ...