在包含稳定函数中使用关键字"and"



我想在"test1和test2"上运行containstable,并希望在关键字"one_answers"上运行测试。

但是下面的代码给了我一个错误:

containstable(table_name, column_name, 'test1 AND "and" test2')

来自MSDN的语法没有指示是否允许使用这些关键字,以及是否可以使用这些关键字。

谢谢,布鲁斯

http://msdn.microsoft.com/en-us/library/ms189760.aspx

和其中一个示例与您的测试类似。

containstable(table, column, '("sweet and savory" NEAR sauces) OR
    ("sweet and savory" NEAR candies)')

修改约束以匹配您的数据

编辑:我还应该指定'test1 AND "and" test2'在任何情况下都不是布尔条件。试一试:

'(test1 AND "and") OR (test2 AND "and")'

或类似的值将计算为布尔条件

我找到了,答案是:

containstable(table_name, column_name, 'test1 AND "and test2"') 

请注意,双引号在"and test2"周围,而不仅仅是"and"