SQL 以任意顺序选择 Like 关键字 [英] SQL Select Like Keywords in Any Order

查看:29
本文介绍了SQL 以任意顺序选择 Like 关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为购物车站点构建搜索功能,该功能可查询 SQL Server 数据库.当用户在搜索框中输入Hula Hoops"时,我想要以任何顺序包含Hula"和Hoop"的所有记录的结果.此外,我需要搜索多个列(即产品名称、描述、短名称、制造商名称等)

I am building a Search function for a shopping cart site, which queries a SQL Server database. When the user enters "Hula Hoops" in the search box, I want results for all records containing both "Hula" and "Hoop", in any order. Furthermore, I need to search multiple columns (i.e. ProductName, Description, ShortName, MaufacturerName, etc.)

搜索呼啦圈"时,应返回所有这些产品名称:

All of these product names should be returned, when searching for "Hula hoop":

  • 呼啦圈
  • 呼啦圈
  • xxhula 棒的 Hoopity

(如果这些可以按相关性排序,则加分!)

(Bonus points if these can be ordered by relevance!)

推荐答案

SQL Server 全文搜索应该可以帮到你.您基本上将在要搜索的列上创建索引.在查询的 where 子句中,您将使用 CONTAINS 运算符并将其传递给您的搜索输入.

SQL Server Full Text Search should help you out. You will basically create indexes on the columns you want to search. in the where clause of your query you will use the CONTAINS operator and pass it your search input.

您可以开始HERE这里了解更多

you can start HERE or HERE to learn more

这篇关于SQL 以任意顺序选择 Like 关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆