This article mainly introduces the usage of the Contains function in Oracle. To query students whose address is in a certain city, the sql statement is introduced to you in great detail. Friends who need it can refer to it. I hope it can help everyone.
1. Query students whose address is in Beijing
SELECT student_id,student_name FROM students WHERE CONTAINS( address, 'beijing' )
#remark: beijing is a word, use single quotes bracketed.
2. Query students whose address is in Hebei Province
SELECT student_id,student_nameFROM students WHERE CONTAINS( address, '"HEIBEI province"' )
#remark: HEBEI province is a phrase, in a single word Also use double quotes within quotation marks.
3. Query students whose addresses are in Hebei Province or Beijing
SELECT student_id,student_nameFROM students WHERE CONTAINS( address, '"HEIBEI province" OR beijing' )
remark: Logical operators can be specified ( Including AND, AND NOT, OR).
4. Query the address with the words 'Nanjing Road'
SELECT student_id,student_name FROM students WHERE CONTAINS( address, 'nanjing NEAR road' )
remark: The above query will return the address containing Addresses with the words 'nanjing road', 'nanjing east road', 'nanjing west road', etc.
A NEAR B means the condition: A is close to B.
5. Query for addresses starting with 'lake'
SELECT student_id,student_name FROM students WHERE CONTAINS( address, '"hu*"' )
#remark: The above query will return addresses containing ' hubei', 'hunan', etc. addresses.
Remember it’s *, not %.
6. Similar weighted queries
SELECT student_id,student_name FROM students WHERE CONTAINS( address, 'ISABOUT (city weight (.8), county wright (.4))' )
remark: ISABOUT is the keyword for this kind of query, weight is specified A number between 0 and 1, similar to a coefficient (my understanding). Indicates that different conditions have different emphasis.
7. Polymorphic query for words
SELECT student_id,student_name FROM students WHERE CONTAINS( address, 'FORMSOF (INFLECTIONAL,street)' )
remark: The query will return items containing 'street', 'streets' ' and other words in the address.
For the verb will return to its different tense, such as: DRY, it will return to DRY, DRIED, DRYING and so on.
8. Word query example
A word query is a query for the exact word or phrase entered into the CONTAINS operator between single quotes. In the following example, we will find all documents that contain the word oracle in the text column. The score for each row is selected by the SCORE operator using tag 1:
SELECT SCORE(1) title from news WHERE CONTAINS(text,'oracle',1)> 0;
In query expressions, you can use textual operators such as AND and OR to obtain different results. You can also add structural predicates to the WHERE clause. You can use count(*), CTX_QUERY.COUNT_HITS, or CTX_QUERY.EXPLAIN to count the number of hits (matches) for a query.
9 ABOUT Query Example
In all languages, the ABOUT query increases the number of related documents returned by a query. In English, ABOUT queries can use the subject heading component of the index, which is created by default. This way, the operator returns documents based on the concept of the query, rather than just the exact word or phrase you specified. For example, the following query will find all documents in the text column on the topic politics, rather than documents containing just the word politics:
SELECT SCORE(1) title from news WHERE CONTAINS(text, 'about(politics)', 1) > 0;
Did you learn it? Hurry up and try it yourself.
Related recommendations:
Full text index—CONTAINS syntax
JQuery contains selector_jquery
The above is the detailed content of Summary of usage of Contains function in Oracle. For more information, please follow other related articles on the PHP Chinese website!