View previous topic :: View next topic |
Author |
Message |
mf_user Intermediate
Joined: 01 Jun 2003 Posts: 372 Topics: 105
|
Posted: Thu Dec 11, 2008 6:04 am Post subject: When Condition for two values |
|
|
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
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 |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Thu Dec 11, 2008 7:10 am Post subject: |
|
|
????
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 |
|
|
CraigG Intermediate
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
|
Posted: Thu Dec 11, 2008 7:19 am Post subject: |
|
|
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 |
|
|
mf_user Intermediate
Joined: 01 Jun 2003 Posts: 372 Topics: 105
|
Posted: Fri Dec 12, 2008 9:40 am Post subject: |
|
|
CraigG, I have tried it with AND condition but gives me 0 rows _________________ MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
== |
|
Back to top |
|
|
jsharon1248 Intermediate
Joined: 08 Aug 2007 Posts: 291 Topics: 2 Location: Chicago
|
Posted: Fri Dec 12, 2008 10:34 am Post subject: |
|
|
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 |
|
|
|
|