开发者

Escape SQL Full Text Conditional Keywords

开发者 https://www.devze.com 2023-02-09 19:17 出处:网络
Can anyone tell me how to have keywords like \"AND\" and \"OR\" in the actual search query itself and not get an error? For example:

Can anyone tell me how to have keywords like "AND" and "OR" in the actual search query itself and not get an error? For example:

SEL开发者_StackOverflow中文版ECT *
FROM MyTable
WHERE CONTAINS(MyColumn, 'This and')

I keep getting this error:

Syntax error near 'and' in the full-text search condition 'This and'

Perfectly understandable why there is an error, but how do I ignore the keyword and just have the "and" as part of the search phrase?

Thanks


If this is about MS SQL, then I think you will have to write

SELECT *
FROM MyTable
WHERE CONTAINS(MyColumn, '"This and"')

Note the double quotes

0

精彩评论

暂无评论...
验证码 换一张
取 消