Reputation: 1514
I am having a table name Product
contains 3 columns as:
Product-id
name
Price
In name
column, all product names are present.
Example: 1340 GPS, 1340T GPS etc.
When I write
select top 10 * from product where contains(name,'1340');
Result 1 row 1340 GPS
but when I search
select top 10 * from product where name like '%1340%';
Then the result is 1340 GPS and 1340T GPS
.
Actually my requirement is I will use contains()
but it has to show both the rows like LIKE
operator.
How to do so :?
Please help
Thanks in advance
Upvotes: 12
Views: 118542
Reputation: 2780
Here is straight way to do this . you can use "*" before in contain syntax same as like operator . but you need to use double quote before and after the search string . check following query :
SELECT *
FROM product
WHERE CONTAINS(name,'"*1340*"');
it will definitely work .
Upvotes: 15