March 15, 2016 at 7:03 am
I have to put together a Query statement and I am looking for a way to do something with an Everything BUT, I have maybe 2000 plus unique Identifiers for a Field in a table however I only want to pull all but the following "OUT,NAB,NHB". Not really sure how to do this?
The field in the database is called "chppon"
March 15, 2016 at 7:08 am
You need to use NOT IN.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
March 15, 2016 at 7:11 am
can you give me an example of how to place that statement?
Does it go in the FROM section or the WHERE section?
March 15, 2016 at 7:11 am
WHERE [column] not in ('x','y','z')
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
March 15, 2016 at 7:58 am
Phil Parkin (3/15/2016)
WHERE [column] not in ('x','y','z')
So in order to Flip this Statement to True what would I change "Not in" too?
March 15, 2016 at 8:00 am
To remove the negation, remove the NOT. So IN.
But Phil's code does exactly what you asked. It would return all rows except the ones that have the value of x, y or z.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 15, 2016 at 8:04 am
Yes it worked. I just wanted to make sure incase I need to run the other direction as this query is about 12 pages long already. Working with over 300 tables and billions of records. Just looked at it so much I feel brain dead.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply