开发者

LIKE operator in SQL Server

开发者 https://www.devze.com 2022-12-24 10:14 出处:网络
I want to get all the records from the one t开发者_如何学Goable which contain at least one word from the input string. For example, input parameter=\'Stack over flow\':

I want to get all the records from the one t开发者_如何学Goable which contain at least one word from the input string. For example, input parameter='Stack over flow':

select *
from sample
where  name like '%stack%'
    or name like '%over%'
    or name like '%flow%'

How do I search for records which contains 'stack' or 'over' or 'flow'?


The code you gave should work. But don't use it. It won't be able to use any indexes, and so will likely be very slow. Look into a full text index and the CONTAINS keyword instead.

0

精彩评论

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