|
View previous topic :: View next topic
|
| Author |
Message |
ksathishkumar83
New User
Joined: 21 Nov 2006 Posts: 50 Location: India
|
|
|
|
Hi,
I have table as below:
| Code: |
Col1 Col2 COl3
A 1 dd
A 3 ff
A 3 ss
B 3 ee |
| Code: |
Select col3 from table1
where col1 ='A' or Col2='3'. |
Output:
---------
The second and third row should not be selected.If Col1='A' it should not check for COl2 condition.
I tried splitting into two queries.But i am trying to find the solution in single query. |
|
| Back to top |
|
 |
Akatsukami
Global Moderator

Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
| Your post is ambiguous. Is the output you show the desired output or the actual output? |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
Your post is clear as mud ...
are You complaining that the <select> You posted does not satisfy Your requirement or what ?
post Your input data, what You expect, without foggy comments, please
if the output is what is expected
the logic should be ...
( col1 = "A" or col2 = "3" ) and ( not ( col1 = "A" and col2 = "3" ) )
I do not speak SQLese any longer, so a translator will be required |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Your requirement is not clear for me atleast
When you say 2nd row and 3rd row does it mean the row id?
What is the SPECIAL business need about 2nd row and 3rd row? |
|
| Back to top |
|
 |
ksathishkumar83
New User
Joined: 21 Nov 2006 Posts: 50 Location: India
|
|
|
|
| The output shown is the desired output. |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Or Do you want to pick the data which doesnt have 'A' and '3' together
If yes tell me what did you try? |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
Pandora,
the TS does NOT want the data with A and 3 |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
| Code: |
where (col1 = A and col2 <> 3)
or (col1 <> A and col2 = 3) |
Should do
Thanks Enrico |
|
| Back to top |
|
 |
Akatsukami
Global Moderator

Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
Amazing; SQL does not have an XOR operator!  |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
| Quote: |
| If Col1='A' it should not check for COl2 condition. |
Is this really true or is this a typo? |
|
| Back to top |
|
 |
|
|