In Oracle, you can use the like keyword in the where clause to achieve fuzzy query effects. The character matching operation can use wildcards "%" and "_", and the syntax is "SELECT * FROM user WHERE column name LIKE 'fuzzy query field'".
The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.
In this era where the amount of information is increasing dramatically, fuzzy query is essential to help users retrieve the desired data from massive amounts of data. So how is fuzzy query implemented in Oracle?
We can use the like keyword in the where clause to achieve the effect of Oracle fuzzy query; in the where clause, we can use the Like keyword with wildcards for columns of datetime, char, and varchar field types. Fuzzy query, the following are the wildcard characters that can be used:
The most commonly used and simplest way is to use "%" and "_".
Wildcard characters "%" and "_" can be used for character matching operations:
%: represents any number of characters, including zero;
_: represents any character;
The escape keyword implements like matching of special characters and the escape of & characters.
For example:
SQL> select * from dept; DEPTNO DNAME LOC ------ -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON
"%" and "_" Demonstration:
SQL> select * from dept where DNAME like '_A%'; DEPTNO DNAME LOC ------ -------------- ------------- 30 SALES CHICAGO
Recommended tutorial: "Oracle Video Tutorial"
The above is the detailed content of What is Oracle fuzzy query statement?. For more information, please follow other related articles on the PHP Chinese website!