Full-text index—CONTAINS syntax_PHP tutorial
Full-text index - CONTAINS syntax
We usually use CONTAINS in the WHERE clause, like this: SELECT * FROM table_name WHERE CONTAINS(fullText_column,'search contents').
Let’s learn through examples. Suppose there is a table students, in which address is a column for full-text retrieval.
1. Query students whose address is in Beijing
SELECT student_id,student_name
FROM students
WHERE CONTAINS( address, 'beijing' )
remark: beijing is a word and should be enclosed in single quotes stand up.
2. Query students whose address is in Hebei Province
SELECT student_id,student_name
FROM students
WHERE CONTAINS( address, '"HEIBEI province"' )
remark: HEBEI province is a phrase, Also use double quotes within single quotes.
3. Query students whose addresses are in Hebei Province or Beijing
SELECT student_id,student_name
FROM students
WHERE CONTAINS( address, '"HEIBEI province" OR beijing' )
remark: can be specified Logical operators (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 Addresses containing the words 'nanjing road', 'nanjing east road', 'nanjing west road', etc.
A NEAR B means condition: A is close to B.
5. Query the address starting with '湖'
SELECT student_id,student_name
FROM students
WHERE CONTAINS( address, '"hu*"' )
remark: The above query will return Addresses containing the words 'hubei', 'hunan', etc.
Remember it’s *, not %.
6. Similar weighted query
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, and weight specifies a number between 0 and 1, similar to a coefficient (my understanding). Indicates that different conditions have different emphasis.
7. Polymorphic query of 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 address.
For a verb, it will return its different tenses, such as: dry, which will return dry, dried, drying, etc.
The above examples are all in English. Chinese is not used because some query methods are not supported in Chinese, and my computer is an English system.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Oracle index types include: 1. B-Tree index; 2. Bitmap index; 3. Function index; 4. Hash index; 5. Reverse key index; 6. Local index; 7. Global index; 8. Domain index ; 9. Bitmap connection index; 10. Composite index. Detailed introduction: 1. B-Tree index is a self-balancing tree data structure that can efficiently support concurrent operations. In Oracle database, B-Tree index is the most commonly used index type; 2. Bit Graph index is an index type based on bitmap algorithm and so on.

Lambda expression is an anonymous function without a name, and its syntax is: (parameter_list)->expression. They feature anonymity, diversity, currying, and closure. In practical applications, Lambda expressions can be used to define functions concisely, such as the summation function sum_lambda=lambdax,y:x+y, and apply the map() function to the list to perform the summation operation.

Practical Guide to Where Method in Laravel Collections During the development of the Laravel framework, collections are a very useful data structure that provide rich methods to manipulate data. Among them, the Where method is a commonly used filtering method that can filter elements in a collection based on specified conditions. This article will introduce the use of the Where method in Laravel collections and demonstrate its usage through specific code examples. 1. Basic usage of Where method

This article will explain in detail how PHP returns the string from the start position to the end position of a string in another string. The editor thinks it is quite practical, so I share it with you as a reference. I hope you will finish reading this article. You can gain something from this article. Use the substr() function in PHP to extract substrings from a string. The substr() function can extract characters within a specified range from a string. The syntax is as follows: substr(string,start,length) where: string: the original string from which the substring is to be extracted. start: The index of the starting position of the substring (starting from 0). length (optional): The length of the substring. If not specified, then

How to improve the efficiency of data grouping and data aggregation in PHP and MySQL through indexes? Introduction: PHP and MySQL are currently the most widely used programming languages and database management systems, and are often used to build web applications and process large amounts of data. Data grouping and data aggregation are common operations when processing large amounts of data, but if indexes are not designed and used appropriately, these operations can become very inefficient. This article will introduce how to use indexes to improve the efficiency of data grouping and data aggregation in PHP and MySQL, and improve

The solutions are: 1. Check whether the index value is correct: first confirm whether your index value exceeds the length range of the array. The index of the array starts from 0, so the maximum index value should be the array length minus 1; 2. Check the loop boundary conditions: If you use the index for array access in a loop, make sure the loop boundary conditions are correct; 3. Initialize the array: Before using an array, make sure that the array has been initialized correctly; 4. Use exception handling: You can use the exception handling mechanism in the program to catch errors where the index exceeds the bounds of the array, and handle it accordingly.

The connection and difference between Go language and JS Go language (also known as Golang) and JavaScript (JS) are currently popular programming languages. They are related in some aspects and have obvious differences in other aspects. This article will explore the connections and differences between the Go language and JavaScript, and provide specific code examples to help readers better understand these two programming languages. Connection: Both Go language and JavaScript are cross-platform and can run on different operating systems.

How to use the Where method in Laravel collection Laravel is a popular PHP framework that provides a wealth of functions and tools to facilitate developers to quickly build applications. Among them, Collection is a very practical and powerful data structure in Laravel. Developers can use collections to perform various operations on data, such as filtering, mapping, sorting, etc. In collections, the Where method is a commonly used method for filtering the collection based on specified conditions.
