SQL Server 2: full-text search (2)

Source: Internet
Author: User

Here we will focus on the contains function used in full-text search to extract others'Article, I feel like I have written it. I 'd like to share it with you.

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

1 . Query students whose addresses are 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. Download dl.bitscn.com

2. Query student addresses in Hebei Province
SelectStudent_id, student_name
FromStudents
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
SelectStudent_id, student_name
FromStudents
WhereContains(Address,'"Heibei province" or Beijing')
Remark: You can specify logical operators (includingAnd,AndNot,Or).

Download dl.bitscn.com

4 . The query has ' Nanjing Road ' Address
Select Student_id, student_name
From Students
Where Contains (Address, ' Nanjing near Road ' )
Remark: The above query will return the include ' Nanjing Road ' , ' Nanjing East Road ' , ' Nanjing West Road ' .
A near B indicates that A is near B.

Www.bitscn.com

5 . Query ' Lake ' Address starting
Select Student_id, student_name
From Students
Where Contains (Address, ' "Hu *" ' )
Remark: The above query will return the include ' Hubei ' , ' Hunan ' .
Remember: * , No % .

Network Management Forum bbs_bitscn_com

6. Weighted Query
SelectStudent_id, student_name
FromStudents
WhereContains(Address,'Isabout (city weight (. 8), county Wright (. 4 ))')
Remark: isabout is the keyword of this query. Weight specifies0~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
Where Contains (Address, ' Formsof (inflectional, Street) ' )
Remark: The query returns include ' Street ' , ' Streets ' .
For a verb, different tenses are returned, such as dry, dry, dried, drying, and so on.

This article is from the csdn blog. For more information, see http://Blog.csdn.net/Htl258/Archive/2009/03/17/3996728. Aspx

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.