MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

When Condition for two values

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Thu Dec 11, 2008 6:04 am    Post subject: When Condition for two values Reply with quote

Hi,

I want to select rows from a table where the same field having both the values (Not either).

We have a table where a field can have multiple values.

Example:
Code:

Table: CONS_DATA
Field Name: CONS_DATA_INSTNC
Length: 3
Type: Character
Possible Values: 1CK, 0MT,  1MT, 0CK, S0Y, SMT, SCK


On a particular record, all values may or may NOT appear. I want to select only those records that have 1CK & SCK as CONS_DATA_INSTNC.

If I use WHERE CONS_DATA_INSTNC IN ('1CK','SCK') then it is selecting records based on either or condition Crying or Very sad

Please suggest the query.

Thanks.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Thu Dec 11, 2008 7:10 am    Post subject: Reply with quote

????

it is a 3 char column.
So, how could 1 row contain a column,
which is defined as CHAR(03),
which has 6 char?

I don't understand how a 3 char column could contain 1ck and sck.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Thu Dec 11, 2008 7:19 am    Post subject: Reply with quote

You could code it as "WHERE CONS_DATA_INSTNC = '1CK' AND CONS_DATA_INSTNC = 'SCK'"

a more efficient way whould that would return the same results would be
"WHERE 1 = 2"
Back to top
View user's profile Send private message
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Fri Dec 12, 2008 9:40 am    Post subject: Reply with quote

CraigG, I have tried it with AND condition but gives me 0 rows Sad
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Fri Dec 12, 2008 10:34 am    Post subject: Reply with quote

What kind of special DB options are you using that the column value on a row can contain 2 values? You need to think about what you're saying. It doesn't make sense.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group