Solved

SQL 2005 SELECT Statement "NOT CONTAINS 'cat'"

Posted on 2007-11-28
3
1,212 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 400 total points
ID: 20368307
SELECT   DISTINCT merchantCategory
FROM     dbo.Items
 WHERE merchantCategory NOT LIKE '%cat%'
0
 
LVL 9

Assisted Solution

by:CCongdon
CCongdon earned 100 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

726 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