`
i3587616
  • 浏览: 20098 次
  • 性别: Icon_minigender_1
  • 来自: 厦门
社区版块
存档分类
最新评论

mysql 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 条件
0
0
分享到:
评论

相关推荐

    MySQL多种递归查询方法.docx

    find_in_set 函数 concat,concat_ws,group_concat 函数 MySQL 自定义函数 手动实现 MySQL 递归查询 Oracle 递归查询 在 Oracle 中是通过 start with connect by prior 语法来实现递归查询的。 按照 prior ...

    A Guide for Migrating From Oracle to MySQL

    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...

    mysql-5.5.43.tar.gz

    # 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 ...

    mysql-8.0.20-macos10.15-x86_64.tar.gz

    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官网下载,如果比较慢, 从...

    MySQL and JSON A Practical Programming Guide 2018

    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 ...

    Linux系统安装oracle数据库保姆教程

    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` 安装新版...

    DoctrineExtensions:一组Doctrine 2扩展

    教义扩展 Doctrine 2的一组扩展,增加了对MySQL,Oracle,PostgreSQL和SQLite中可用...FORMAT, DATEADD, DATEDIFF, DATESUB, DAY, DAYNAME, DAYOFWEEK, DAYOFYEAR, DEGREES, DIV, EXP, EXTRACT, FIELD, FIND_IN_SET

    php.ini-development

    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 ...

    SQL袖珍参考手册(第3版)

    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 ...

    unidac_7_1_4_pro DELPHI 10 Tokyo

    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_7_1_4_pro DELPHI 10 Berlin

    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 ...

    Seven Databases in Seven Weeks, 2nd

    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-...

    Unidac Pro 7.1.4 XE8

    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 7.1.4

    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 ...

    Devart UniDAC 3.00.0.5 源码安装

    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 ...

    Foundations for Analytics with Python O-Reilly-2016-Clinton W. Brownley

    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 ...

    Delphi7.1 Update

    Delphi 7.1 Update Release Notes=======================================================This file contains important supplemental and late-breakinginformation that may not appear in the main ...

    sqlmap (懂的入)

    * 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 ...

    ssh(structs,spring,hibernate)框架中的上传下载

     本文选用的数据库为Oracle 9i,当然你可以在不改动代码的情况下,通过配置文件的调整将其移植到任何具有Blob字段类型的数据库上,如MySQL,SQLServer等。  总体实现  上传文件保存到T_FILE表中,T_FILE表结构...

    VereORM至简持久层微架构

    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.将解压后 ...

Global site tag (gtag.js) - Google Analytics