如何在sql中搜索单词?

时间:2013-11-06 10:32:23

标签: sql sql-server sql-server-2008

美好的一天。

代码:

column name have rows:

about word test plus
about word tests plus
about word test plus
about word tests plus
about wordtest plus
about wordtests plus
about word testplus
about word testsplus
about wordtestplus
about wordtestsplus

我有SQL查询:

SELECT * FROM TABLE WHERE text LIKE 'test' OR text LIKE 'tests'

请告诉我,如果仅存在全字测试或测试时如何仅选择行?

P.S。在我的例子中,我需要得到行:

about word test plus
about word tests plus
about word test plus
about word tests plus

2 个答案:

答案 0 :(得分:3)

SELECT * FROM TABLE WHERE ' '+text+' ' LIKE '% test %' OR ' '+text+' ' LIKE '% tests %'

答案 1 :(得分:3)

您需要此查询才能获得所需的结果:

SELECT * FROM TABLE WHERE name LIKE '% test %' OR name LIKE '% tests %';