Full-text index-CONTAINS syntax. Full-text index -- CONTAINS syntax we usually use CONTAINS in the WHERE clause, like this: SELECT * FROMtable_nameWHERECONTAINS (fullText_column, searchcontents ). 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 take an example to learn about it. suppose there is a table students, where the address is a full text retrieval column.
1. query student addresses in Beijing
SELECT student_id, student_name
FROM students
Where contains (address, 'Beijing ')
Remark: beijing is a word that must be enclosed in single quotes.
2. query student addresses in Hebei province
SELECT student_id, student_name
FROM students
Where contains (address, '"HEIBEI province "')
Remark: HEBEI province is a phrase that must be enclosed in double quotation marks.
3. query student addresses in Hebei province or Beijing
SELECT student_id, student_name
FROM students
Where contains (address, '"HEIBEI province" OR beijing ')
Remark: you can specify logical operators (including AND, and not, OR ).
4. query the addresses 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 that contain the words "nanjing road", "nanjing east road", and "nanjing west road.
A near B indicates that A is near B.
5. query the address starting with 'hu '.
SELECT student_id, student_name
FROM students
Where contains (address, '"hu *"')
Remark: The preceding query returns an address containing the words 'hubei' and 'hunanc.
Remember: *, not %.
6. Weighted Queries
SELECT student_id, student_name
FROM students
Where contains (address, 'isabout (city weight (. 8), county wright (. 4 ))')
Remark: ISABOUT is the keyword of this query. weight specifies a value ranging from 0 ~ The number between 1, similar to the coefficient (I understand ). Indicates that different conditions have different focuses.
7. multi-state query of words
SELECT student_id, student_name
FROM students
Where contains (address, 'formsof (INFLECTIONAL, street )')
Remark: The query returns the addresses that contain the words 'Street 'and 'Streets.
For a verb, different tenses are returned, such as dry, dry, dried, drying, and so on.
All of the above examples use English, not Chinese because some query methods do not support Chinese, and my computer is an English system.
The explain syntax is usually used in the WHERE clause, just like this: SELECT * FROM table_name where contains (fullText_column, 'search contents '). We...