Full text index-CONTAINS syntax _ PHP Tutorial

Source: Internet
Author: User
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...

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.