Link to home
Start Free TrialLog in
Avatar of saladart
saladart

asked on

NOT CONTAINS

Is there a way to do a NOT CONTAINS query?

I am trying the following but it is not giving me the results I am expecting.

SELECT     ProdNumber, KeyWords
FROM         dbo.Products
WHERE     CONTAINS(KeyWords, 'Kids_Sunglasses') OR
                      CONTAINS(KeyWords, ' "Kids Sunglasses" ') AND (NOT CONTAINS(KeyWords, 'Sunglasses_Infants/Kids'))
ORDER BY ProdNumber

What I am trying to accomplish:

I want all rows by ProdNumber's and Keywords where the keywords field contains the words 'Kids_Sunglasses' or "Kids Sunglasses" but does not also contain the words 'Sunglasses_Infants/Kids'.

Thanks for your assistance!

Saladart
Avatar of rafrancisco
rafrancisco

Try this:

SELECT     ProdNumber, KeyWords
FROM         dbo.Products
WHERE     CONTAINS(KeyWords, ' "Kids_Sunglasses" OR "Kids Sunglasses" AND NOT "Sunglasses_Infants/Kids" ')
ORDER BY ProdNumber
Avatar of saladart

ASKER

Thanks rafrancisco - however, it is still pulling rows that have 'Sunglasses_Infants/Kids' as well as one of the others ('Kids_Sunglasses' or "Kids Sunglasses").  Any other Ideas?  Any questions I can answer to help?

Thanks for trying!

Saladart
ASKER CERTIFIED SOLUTION
Avatar of rafrancisco
rafrancisco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That did it - not sure why, but it worked...

Thanks for your assistance!

Saladart