I am using SQL Server 2008. I have indexed the ProductName
column in the Product
table as full text search index. Some ProductName
values as examples:
ProductName
-------------
Iphone 3GS
Iphone 4S
Iphone 5S
Iphone 5
Now I am using the following code to search for Product
:
WHERE CONTAINS (Product.ProductName, '"Iphone 4S"')
It's OK! But if I edit and use this:
WHERE CONTAINS (Product.ProductName, '"4S Iphone"')
No results!
Could you help me to solve this problem? Thanks.
you want find out results which contain Iphone,4S.So you can use OR condition to get the result.
WHERE CONTAINS (Product.ProductName, '4S OR Iphone')
Following link will be more useful for better understanding. http://blog.sqlauthority.com/2008/09/05/sql-server-creating-full-text-catalog-and-index/
Sounds like you'll want to use the NEAR operator between 4S and Iphone. It searches for words with those, and the order can be independent.
WHERE CONTAINS (Product.ProductName, '"4S" NEAR "Iphone"')
You can also use a tilde(~) in place of the NEAR statement
WHERE CONTAINS (Product.ProductName, '"4S" ~ "Iphone"')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With