Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XOR

Status
Not open for further replies.

jlindahl

Programmer
Sep 23, 2003
46
0
0
US
Can xor be used in sql statements? If not, is there a way I can get one or the other, but not both to be true?
 
where
(first_condition and not second_condition) or
(second_condition and not first_condition)

or

where
(case when first_condition then 1 else 0 end +
case when second_condition then 1 else 0 end) = 1

or

select * from
(
select col1, col2, ...
from tab
where first_condition

union all

select col1, col2, ...
from tab
where second_condition
) dt
group by col1, col2, ...
having count(*) = 1

Dieter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top