在sql server中搜索varchar列的最佳方法

时间:2022-09-15 19:48:13

What would you recommend to search a sql server table (varchar(max) column) for a term?

您建议在一个术语中搜索sql server表(varchar(max)列)?

Let's say, like in ebay, if you search for "wii brand new", you get results like "Brand New Nintendo Wii Fit Game + Balance Board Bundle", "Wii Fit (Wii) BRAND NEW WII FIT GAME + BALANCE BOARD".

让我们说,就像在ebay中,如果你搜索“wii全新”,你会得到像“全新任天堂Wii飞度游戏+平衡板套装”,“Wii Fit(Wii)全新WII适合游戏+平衡板”的结果。

I think it basically searches every word and returns the ones that contains all the words, what would you recommend?

我认为它基本上搜索每个单词并返回包含所有单词的单词,你会推荐什么?

2 个解决方案

#1


4  

You are looking for fulltext indexing, it allows you to do more advanced querying than regular expressions or like.

您正在寻找全文索引,它允许您执行比正则表达式更高级的查询等。

Check this article for a quick introduction, the instructions are for SQL Server 2000, where it is a little harder to setup than in 2005 or 2008.

请查看本文以获得快速介绍,其中的说明适用于SQL Server 2000,它比2005年或2008年更难设置。

Relevant quote:

 With full-text searching, you can perform many other types of search:

 * Two words near each other
 * Any word derived from a particular root (for example run, ran, or running)
 * Multiple words with distinct weightings
 * A word or phrase close to the search word or phrase

#2


1  

Depends on what you are trying to do. For a simple search, you could just do select * from table where field like '%word%'. But if this is some sort of application feature, you want to look into a full tet search application. It can store words that appear in that field as indexes and then search accross those words instead of using that field.

取决于你想要做什么。对于简单的搜索,您可以从表格中选择*,例如'%word%'。但是,如果这是某种应用程序功能,您需要查看完整的tet搜索应用程序。它可以将出现在该字段中的单词存储为索引,然后搜索这些单词而不是使用该字段。

#1


4  

You are looking for fulltext indexing, it allows you to do more advanced querying than regular expressions or like.

您正在寻找全文索引,它允许您执行比正则表达式更高级的查询等。

Check this article for a quick introduction, the instructions are for SQL Server 2000, where it is a little harder to setup than in 2005 or 2008.

请查看本文以获得快速介绍,其中的说明适用于SQL Server 2000,它比2005年或2008年更难设置。

Relevant quote:

 With full-text searching, you can perform many other types of search:

 * Two words near each other
 * Any word derived from a particular root (for example run, ran, or running)
 * Multiple words with distinct weightings
 * A word or phrase close to the search word or phrase

#2


1  

Depends on what you are trying to do. For a simple search, you could just do select * from table where field like '%word%'. But if this is some sort of application feature, you want to look into a full tet search application. It can store words that appear in that field as indexes and then search accross those words instead of using that field.

取决于你想要做什么。对于简单的搜索,您可以从表格中选择*,例如'%word%'。但是,如果这是某种应用程序功能,您需要查看完整的tet搜索应用程序。它可以将出现在该字段中的单词存储为索引,然后搜索这些单词而不是使用该字段。