我是一个SQL新手,如果这是一件简单的话,那就很抱歉
我在sql中的数据是这样的
我的数据:
Content sl.no
KTUU Alaskas News Source Alaskas Top News Storm Watch Weather Politics Sports Health Business Headlines 16419
Lawn Care Business Service Providers Lawn Care Business Information Lawn Mowing Companies Lawn Care Directory 17113
Hydrophilic polyurethane foams medical consumer personal care cosmetics agricultural products Rynel 17183
Care Patient Care Product Manufacturer 17752
Bartlett Tree Experts Leader Residential Commercial Tree Care Services 17890
Safe Earth Lawn & Garden Care 17920
Carolina Outdoor Care Inc 17972
Glenwood Autism Behavioral Health us difference 17997
Mental Health North Central Alabama 18092
East Alabama Mental Health 18093
Jacksonville Mental Health 18094
Mental Health Assn-Madison Cty 18095
Baptist Health Ctr 18136
Mental Health Wellness Information Community Counseling Services 18150
Dayspring Behavioral Health 18162
Daysprings Behavioral Health 18164
Families Outpatient Mental Health Counseling Services 18167
Families Outpatient Mental Health Counseling Services 18168
Health Resources Of Arkansas 18170
Mental Health Council Of Ar 18172
如果我运行以下查询
SELECT TOP 3 * FROM TABLE_NAME where FREETEXT(content,'health care')
我得到前三行而不是前三行 更接近答案
如何获得前三个最相关的查询。
并且查询可以像前一个一样快速
答案 0 :(得分:1)
使用FREETEXTTABLE代替FREETEXT。这将为您提供一系列匹配结果,包括Rank
,您可以通过this了解更多信息
SELECT TOP 3 RANK, [KEY]
FROM FREETEXTTABLE(TABLE_NAME,content,'health care')
ORDER BY RANK DESC
通过KEY
加入以获取原始表格中的列。
SELECT TOP 3 TABLE_NAME.*
FROM FREETEXTTABLE(TABLE_NAME,content,'health care') as fullTextResults
join TABLE_NAME on fullTextResults.[KEY] = TABLE_NAME.Id
ORDER BY fullTextResults.RANK DESC