Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: UNION & MINUS - strange work together at different situation

Re: UNION & MINUS - strange work together at different situation

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Fri, 25 Jan 2002 06:56:57 +0100
Message-ID: <mqs15u0ra27qi6a94llcfguumd6qqmhr73@4ax.com>


On 24 Jan 2002 16:47:45 -0800, y1799_at_yahoo.com (Mike) wrote:

>Hi,
>
>I have two tables: A and B, they both have the same fields. Table A
>contains some records. Table B has the same records and some
>additional records.
>
>If I use such code:
>
> select * from A
> minus
> select * from B
>union
> select * from B
> minus
> select * from A
>
>I get correct result - some string (difference bitween B and A)
>
>But if I use such code
>
> select * from B
> minus
> select * from A
>union
> select * from A
> minus
> select * from B
>
>I get no records as a result. What can be a problem here? Why if last
>part return null string UNION does not work ?
>
>Thanks
>Mike

No doubt this is an issue of MINUS having a higher arithmetic priority than UNION or vice versa. Try using parentheses as should do as often as possible to avoid ambiguous statements like the 2 above.

Hth

Sybrand Bakker, Senior Oracle DBA

To reply remove -verwijderdit from my e-mail address Received on Thu Jan 24 2002 - 23:56:57 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US