比如一张表:
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 条件
分享到:
相关推荐
find_in_set 函数 concat,concat_ws,group_concat 函数 MySQL 自定义函数 手动实现 MySQL 递归查询 Oracle 递归查询 在 Oracle 中是通过 start with connect by prior 语法来实现递归查询的。 按照 prior ...
In particular, many MySQL customers are migrating from Oracle because they have reached the conclusion that the combination of cost-savings and feature set of MySQL make for a compelling business case...
# set that will be compiled in; it's merely provided as a hint to # custom packaging steps. OPTION(COMMUNITY_BUILD "Set to true if this is a community build" ON) # Use a default manufacturer if no ...
Mac OS X 10.15 下源码安装 mysql-8.0.20-macos10.15-x86_64 https://my.oschina.net/kinglyphp/blog/4281112 博客地址 下载mysql-8.0.20-macos10.15-x86_64.tar.gz 可以从mysql官网下载,如果比较慢, 从...
Written by a MySQL Community Manager for Oracle, MySQL and JSON: A Practical Programming Guide shows how to quickly get started using JSON with MySQL and clearly explains the latest tools and ...
4. 查看 MySQL 相关目录:`find / -name mysql` 5. 删除所有 MySQL 相关目录:`rm -rf 目录` 6. 删除 `/etc/my.cnf`:`rm -rf /etc/my.cnf` 7. 删除 `/var/log/mysqld.log`:`rm -rf /var/log/mysqld.log` 安装新版...
教义扩展 Doctrine 2的一组扩展,增加了对MySQL,Oracle,PostgreSQL和SQLite中可用...FORMAT, DATEADD, DATEDIFF, DATESUB, DAY, DAYNAME, DAYOFWEEK, DAYOFYEAR, DEGREES, DIV, EXP, EXTRACT, FIELD, FIND_IN_SET
in production environments and one that is recommended to be used in ; development environments. ; php.ini-production contains settings which hold security, performance and ; best practices at its ...
You'll find many examples that address the language's complexity, along with key aspects of SQL used in IBM DB2 Release 9.7, MySQL 5.1, Oracle Database 11g Release 2, PostgreSQL 9.0, and Microsoft ...
Bug with the FindFirst, FindLast, FindNext, FindPrior methods in Lazarus is fixed Bug with accessing a product help from the IDE menu is fixed Bug with recreating fields when calling Open after ...
Bug with the FindFirst, FindLast, FindNext, FindPrior methods in Lazarus is fixed Bug with accessing a product help from the IDE menu is fixed Bug with recreating fields when calling Open after ...
While relational databases such as MySQL remain as relevant as ever, the alternative, NoSQL paradigm has opened up new horizons in performance and scalability and changed the way we approach data-...
Bug with the FindFirst, FindLast, FindNext, FindPrior methods in Lazarus is fixed Bug with accessing a product help from the IDE menu is fixed Bug with recreating fields when calling Open after ...
Bug with the FindFirst, FindLast, FindNext, FindPrior methods in Lazarus is fixed Bug with accessing a product help from the IDE menu is fixed Bug with recreating fields when calling Open after ...
UniDAC provides a unified inferface to access popular database servers such as Oracle, Microsoft SQL Server, MySQL, PostgreSQL, SQLite, InterBase, Firebird, DB2, Microsoft Access, Advantage Database ...
The first application covers how to find specific records in a large collection of Excel and CSV files. As you can imagine, it’s a lot more efficient and fun to have a computer search for the ...
Delphi 7.1 Update Release Notes=======================================================This file contains important supplemental and late-breakinginformation that may not appear in the main ...
* Full support for MySQL, Oracle, PostgreSQL and Microsoft SQL Server database management system back-end. Besides these four DBMS, sqlmap can also identify Microsoft Access, DB2, Informix and ...
本文选用的数据库为Oracle 9i,当然你可以在不改动代码的情况下,通过配置文件的调整将其移植到任何具有Blob字段类型的数据库上,如MySQL,SQLServer等。 总体实现 上传文件保存到T_FILE表中,T_FILE表结构...
lib/ojdbc14.jar //Oracle 驱动 VereORM.jar 我们以MySQL 为例子只需要下载上面的 4 个驱动包即可 mysql-connector-java-5.1.9.jar dom4j-1.6.1.jar jaxen-1.1-beta-6.jar VereORM.jar 4.将解压后 ...