Oracle like fuzzy query

Source: Internet
Author: User
Tags dname


For LIKE fuzzy search, you can use the wildcard "%" and "_": %: to indicate any character, including zero; _: to indicate any character; SQL code Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 Connected as scott SQL> select * from dept; deptno dname loc ------ ------------ ------------- 10 accounting new york 20 research dallas 30 sales chicago 40 operations boston "%" and "_" Demo: SQL code SQL> select * from dept where DNAME like '_ A %'; deptno dname loc ------ ------------ --------------- 30 sales chicago escape Demo: SQL code SQL> insert into dept values (50, 'beijing', 'jiang % Xi'); 1 row inserted www.2cto.com SQL> select * from dept; deptno dname loc ------ ------------ ------------- 10 accounting new york 20 research dallas 30 sales chicago 40 operations boston 50 beijing jiang % xi SQL> select * from dept where loc like '% \ %' escape '\'; deptno dname loc ------ -------------- ------------- 50 beijing jiang % xi SQL> select * from dept where loc like '% e % 'escape 'E '; deptno dname loc ------ -------------- ------------- 50 beijing jiang % XI from Ear's blog

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.