?
Solved

SQL 2005 SELECT Statement "NOT CONTAINS 'cat'"

Posted on 2007-11-28
3
Medium Priority
?
1,215 Views
Last Modified: 2012-08-13
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
Comment
Question by:jumpstart0321
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1600 total points
ID: 20368307
SELECT   DISTINCT merchantCategory
FROM     dbo.Items
 WHERE merchantCategory NOT LIKE '%cat%'
0
 
LVL 9

Assisted Solution

by:CCongdon
CCongdon earned 400 total points
ID: 20368363
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
 

Author Comment

by:jumpstart0321
ID: 20368374
Thanks guys:)
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question