开发者

SQL Server Freetext Search or other way?

For开发者_高级运维 example I've table with some names:

+-------------------+
| Names             |
+-------------------+
| John Smith Doe    |
| James Black Dean  |
+-------------------+

I'll do a search for:

SQL * FROM TableNames WHERE Names LIKE '%Robert Black%'

But this will not return any results, how could I make it return the result that have Black on the Name, the only way is to use fulltext search?


Are you trying to match Names that contain either 'Robert' or 'Black'? If so, use this query:

SELECT * 
FROM TableNames
WHERE Names LIKE '%Robert%'
    OR Names LIKE '%Black%';


If you want to return a row which has Black you should query like this
SQL * FROM TableNames WHERE Names LIKE '%Black%'

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜