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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exclusive OR

Status
Not open for further replies.

sem

Programmer
Jun 3, 2000
4,709
UA
Does anybody know an efficient technique of getting XOR of 2 queries besides

(query1
union
query2)
minus
(query1
intersect
query2)

It seems to me that each query is executed twice.
 
select data from table where (field = value or field2 = value2) and not(field = value and field2 = value2)
should work
SOL
I'm only guessing but my guess work generally works for me.
 
Supposedly Oracle is smart enough to not execute every query twice (optimization...).
My experience is that unions and minus work generally better than or's, but you can try both approaches anyway.
And having an index over the field/s you select (at least the first one in order) should help you. Union and intersect algorithms order your data before executing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top