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中可以使用freetext或任何其他搜索算法吗?
答案 0 :(得分: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
答案 1 :(得分:0)
添加这个条件怎么样?
OR (@searchparameter = 'wish' and ap.AppName = 'wishpicker')
或者,如果AppName
字段需要通配符:
OR (@searchparameter = 'wish' and ap.AppName like '%wishpicker%')