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
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
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
Thanks for trying!
Saladart
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That did it - not sure why, but it worked...
Thanks for your assistance!
Saladart
Thanks for your assistance!
Saladart
SELECT ProdNumber, KeyWords
FROM dbo.Products
WHERE CONTAINS(KeyWords, ' "Kids_Sunglasses" OR "Kids Sunglasses" AND NOT "Sunglasses_Infants/Kids" ')
ORDER BY ProdNumber