-1
SELECT cat.CategoryId
  ,cat.CategoryImageURL
  ,cat.CategoryName
  ,cat.isDeleted
  ,ap.AppCreatedBy
  ,ap.AppCreatedOn
  ,ap.AppDetails
  ,ap.AppId
  ,ap.AppImageURL
  ,ap.AppModifiedBy
  ,ap.AppModifiedOn
  ,ap.AppName
  ,ap.isDeleted
  ,subcat.SubCategoryId
  ,subcat.SubCategoryName
  ,subcat.SubCategoryImageUrl
FROM Category cat
INNER JOIN App ap
  ON cat.CategoryID = ap.CategoryID
INNER JOIN SubCategory subcat
  ON subcat.SubCategoryId = ap.SubCategoryId
WHERE FREETEXT (
    cat.CategoryName
    ,@searchparameter
    )
  OR FREETEXT (
    subcat.SubCategoryName
    ,@searchparameter
    )
  OR FREETEXT (
    ap.AppName
    ,@searchparameter
    )
  OR CONTAINS (
    ap.AppDetails
    ,@searchparameter
    )
  OR CONTAINS (
    cat.CategoryName
    ,@searchparameter
    )
  OR CONTAINS (
    subcat.SubCategoryName
    ,@searchparameter
    )
  OR CONTAINS (
    ap.AppName
    ,@searchparameter
    )
  OR CONTAINS (
    ap.AppDetails
    ,@searchparameter
    )

USE [AppStore]
GO

DECLARE @return_value INT

EXEC @return_value = [dbo].[IndianAppStore_Search] @searchparameter = N'wishpicker'

SELECT 'Return Value' = @return_value
GO

在 App 表的 AppName 列中,有一行包含 wishpicker 作为 AppName 我想显示这个结果,即使用户只写了搜索查询的愿望。

使用自由文本或 sql server 中的任何其他搜索算法是否有可能?

4

2 回答 2

1

阅读 LIKE 关键字。但总之...

WHERE (ap.AppName LIKE 'wish%')  -- Finds app names BEGINNING with wish
WHERE (ap.AppName LIKE '%wish%') -- Finds app names CONTAINING wish
WHERE (ap.AppName LIKE '%wish')  -- Finds app names ENDING with wish
于 2013-08-16T12:46:32.070 回答
0

添加这个条件怎么样?

OR (@searchparameter = 'wish' and ap.AppName = 'wishpicker')

或者,如果该AppName字段需要通配符:

OR (@searchparameter = 'wish' and ap.AppName like '%wishpicker%')
于 2013-08-16T11:24:15.970 回答