我想知道如何使用CONTAINSTABLE
构建动态或条件?
计算chain0,chain1,chain2中的任何一个都可以为空,无论顺序如何。我想做(1 = 0) OR
之类的事情...例如,第一个是空的,但它不起作用
例如
declare @chain NVARCHAR(MAX) = ''
declare @chain0 NVARCHAR(100) = '(FORMSOF(INFLECTIONAL, "cat") AND FORMSOF(INFLECTIONAL, "dog"))'
declare @chain1 NVARCHAR(100) = '(FORMSOF(INFLECTIONAL, "parrot") AND FORMSOF(INFLECTIONAL, "snake"))'
declare @chain2 NVARCHAR(100) = '(FORMSOF(INFLECTIONAL, "pig") AND FORMSOF(INFLECTIONAL, "leon"))'
IF @chain0 <> ''
BEGIN
SELECT @chain = @chain + ' OR ' + @chain0
END
IF @chain1 <> ''
BEGIN
SELECT @chain = @chain + ' OR ' + @chain1
END
IF @chain2 <> ''
BEGIN
SELECT @chain = @chain + ' OR ' + @chain2
END
SELECT *
FROM CONTAINSTABLE(TableAnimals, Title, @chain, @LenguageID) AS CT