給個例子給你: USE Northwind GO SELECT FT_TBL.Description, FT_TBL.CategoryName, KEY_TBL.RANK FROM Categories AS FT_TBL INNER JOIN CONTAINSTABLE (Categories, Description, '("sweet and savory" NEAR sauces) OR ("sweet and savory" NEAR candies)' ) AS KEY_TBL ON FT_TBL.CategoryID = KEY_TBL.[KEY] WHERE KEY_TBL.RANK > 2 AND FT_TBL.CategoryName <> 'Seafood' ORDER BY KEY_TBL.RANK DESC
char(20)没有必要用全文索引吧.
要先建立全文索引才能使用CONTAINSTABLEselect * from tbase where '123456' in (hy1,hy2,hy2,hy4)
如果数据量少,可以直接查找 包含的情况 select * from tbase where hy1 like '%123456%' or hy2 like '%123456%' or hy3 like '%123456%' or hy4 like '%123456%'全部匹配的情况 select * from tbase where hy1='123456' or hy2='123456' or hy3='123456' or hy4='123456'
USE Northwind
GO
SELECT FT_TBL.Description,
FT_TBL.CategoryName,
KEY_TBL.RANK
FROM Categories AS FT_TBL INNER JOIN
CONTAINSTABLE (Categories, Description,
'("sweet and savory" NEAR sauces) OR
("sweet and savory" NEAR candies)'
) AS KEY_TBL
ON FT_TBL.CategoryID = KEY_TBL.[KEY]
WHERE KEY_TBL.RANK > 2
AND FT_TBL.CategoryName <> 'Seafood'
ORDER BY KEY_TBL.RANK DESC
char(20)没有必要用全文索引吧.
where '123456' in (hy1,hy2,hy2,hy4)
包含的情况
select * from tbase where hy1 like '%123456%'
or hy2 like '%123456%'
or hy3 like '%123456%'
or hy4 like '%123456%'全部匹配的情况
select * from tbase where hy1='123456'
or hy2='123456'
or hy3='123456'
or hy4='123456'