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.