• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1219
  • Last Modified:

SQL 2005 SELECT Statement "NOT CONTAINS 'cat'"

Here's the SQL statement I'm trying to execute!
SELECT       DISTINCT merchantCategory
FROM            dbo.Items
WHERE NOT CONTAINS 'cat'
In other words, I want it to cough up all the unique results for merchantCategory that don't contain the keyword 'cat'. I know the syntax is wrong somewhere around 'cat'; I'm just not sure what it is. Please help, Thanks, Chris.
0
jumpstart0321
Asked:
jumpstart0321
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
SELECT   DISTINCT merchantCategory
FROM     dbo.Items
 WHERE merchantCategory NOT LIKE '%cat%'
0
 
CCongdonCommented:
Building from angellll's query, you might change the WHERE to read

WHERE merchantCategory NOT LIKE 'cat%'

if what you are looking for STARTS with the phrase 'cat' Othewise, you might block something that mereley has the phrase cat in the middle of it. Like the word 'scathing' -- sCAThing.
0
 
jumpstart0321Author Commented:
Thanks guys:)
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Tackle projects and never again get stuck behind a technical roadblock.
Join Now