SQL Basics

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDatabasesSQL Basics

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old October 22nd, 2015, 09:21 PM
rourlogan rourlogan is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Oct 2015
Posts: 1 rourlogan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 3 m 18 sec
Reputation Power: 0
Need help with a query ALL rows in column must meet condition

Hello all! My first post here, looking for a little bit of help

I only want the query to return rows that ONLY have ABC, DEF, GHI, but if even one row has XXX or ZZZ then it doesnt return that ID at all.

Here's what the table looks like..

UniqID | Status

1 | ABC
1 | DEF
1 | GHI
1 | XXX
1 | ZZZ
2 | ABC

My code looks like this

Select UniqID
From #table5
WHERE STATUS = 'ABC' Or Status = 'DEF' Or Status = 'GHI

The problem here is that it returns the rows that DO meet this condition I just don't know how to tell it to ignore them if they have any of the XXX or ZZZ in the rows.

Any help is appreciated thanks!

Reply With Quote
  #2  
Old November 3rd, 2015, 03:15 AM
Thinker8 Thinker8 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Nov 2015
Posts: 2 Thinker8 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by rourlogan
Hello all! My first post here, looking for a little bit of help

I only want the query to return rows that ONLY have ABC, DEF, GHI, but if even one row has XXX or ZZZ then it doesnt return that ID at all.

Here's what the table looks like..

UniqID | Status

1 | ABC
1 | DEF
1 | GHI
1 | XXX
1 | ZZZ
2 | ABC

My code looks like this

Select UniqID
From #table5
WHERE STATUS = 'ABC' Or Status = 'DEF' Or Status = 'GHI

The problem here is that it returns the rows that DO meet this condition I just don't know how to tell it to ignore them if they have any of the XXX or ZZZ in the rows.

Any help is appreciated thanks!


Try this one!!!
Select UniqID, STATUS from #table5 where STATUS in ('ABC','DEF','GHI');

Reply With Quote
Reply

Viewing: Tutorialized ForumsDatabasesSQL Basics > Need help with a query ALL rows in column must meet condition


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap