Oracle like fuzzy query

Source: Internet
Author: User
Tags dname

LIKE fuzzy query

The wildcard characters "%" and "_" can be used for character matching:

%: Represents any character, including zero;

_: Represents any character;

  1. ConnectedToOracleDatabase11g Enterprise Edition Release 11.2.0.1.0
  2. ConnectedAsScott
  3. SQL>Select*FromDept;
  4. DEPTNO DNAME LOC
  5. ---------------------------------
  6. 10 ACCOUNTING NEW YORK
  7. 20 RESEARCH DALLAS
  8. 30 SALES CHICAGO
  9. 40 OPERATIONS BOSTON

"%" And "_" Demo:

  1. SQL>Select*FromDeptWhereDNAMELike '_ A %';
  2. DEPTNO DNAME LOC
  3. ---------------------------------
  4. 30 SALES CHICAGO

ESCAPE Demo:

  1. SQL>Insert IntoDeptValues(50,'Beijing','Jiang % Xi');
  2. 1 row inserted
  3. SQL>Select*FromDept;
  4. DEPTNO DNAME LOC
  5. ---------------------------------
  6. 10 ACCOUNTING NEW YORK
  7. 20 RESEARCH DALLAS
  8. 30 SALES CHICAGO
  9. 40 OPERATIONS BOSTON
  10. 50 beijing jiang % XI
  11. SQL>Select*FromDeptWhereLocLike '% \ %' Escape '\';
  12. DEPTNO DNAME LOC
  13. ---------------------------------
  14. 50 beijing jiang % XI
  15. SQL>Select*FromDeptWhereLocLike '% E %' Escape 'E';
  16. DEPTNO DNAME LOC
  17. ---------------------------------
  18. 50 beijing jiang % XI

For more information about Oracle, see Oracle topics page http://www.bkjia.com/topicnews.aspx? Tid = 12

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.