SQL Server 2: full-text search (2) SQL Server 2: full-text search (2)

Source: Internet
Author: User
SQL Server 2: full-text search (2)

Here we will mainly talk about the contains function used in full-text search, extract articles from others, and share it with you.

Suppose there is a table named students, where the address is a column for full text search.

1. query student addresses in Beijing
Select student_id, student_name
From students
Wherecontains (address, 'beijing ')
Remark: Beijing is a word that must be enclosed in single quotes. Download dl.bitscn.com

2. query student addresses in Hebei Province
Select student_id, student_name
From students
Wherecontains (address, '"Heibei province "')
Remark: Hebei province is a phrase that must be enclosed in double quotation marks.

China Network Management Forum bbs.bitscn.com

3. query student addresses in Hebei province or Beijing
Select student_id, student_name
From students
Wherecontains (address, '"Heibei province" or Beijing ')
Remark: You can specify logical operators (including and, Andnot, or ).

Download dl.bitscn.com

4. query the addresses with the words "Nanjing Road"
Select student_id, student_name
From students
Wherecontains (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.

Www.bitscn.com

5. query the address starting with 'hu '.
Select student_id, student_name
From students
Wherecontains (address, '"Hu *"')
Remark: The preceding query returns an address containing the words 'hubei' and 'hunanc.
Remember: *, not %.

Network Management Forum bbs_bitscn_com

6. Weighted queries
Select student_id, student_name
From students
Wherecontains (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. Download dl.bitscn.com

7. multi-state query of words
Select student_id, student_name
From students
Wherecontains (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.

Here we will mainly talk about the contains function used in full-text search, extract articles from others, and share it with you.

Suppose there is a table named students, where the address is a column for full text search.

1. query student addresses in Beijing
Select student_id, student_name
From students
Wherecontains (address, 'beijing ')
Remark: Beijing is a word that must be enclosed in single quotes. Download dl.bitscn.com

2. query student addresses in Hebei Province
Select student_id, student_name
From students
Wherecontains (address, '"Heibei province "')
Remark: Hebei province is a phrase that must be enclosed in double quotation marks.

China Network Management Forum bbs.bitscn.com

3. query student addresses in Hebei province or Beijing
Select student_id, student_name
From students
Wherecontains (address, '"Heibei province" or Beijing ')
Remark: You can specify logical operators (including and, Andnot, or ).

Download dl.bitscn.com

4. query the addresses with the words "Nanjing Road"
Select student_id, student_name
From students
Wherecontains (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.

Www.bitscn.com

5. query the address starting with 'hu '.
Select student_id, student_name
From students
Wherecontains (address, '"Hu *"')
Remark: The preceding query returns an address containing the words 'hubei' and 'hunanc.
Remember: *, not %.

Network Management Forum bbs_bitscn_com

6. Weighted queries
Select student_id, student_name
From students
Wherecontains (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. Download dl.bitscn.com

7. multi-state query of words
Select student_id, student_name
From students
Wherecontains (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.

Related Article

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.