Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> REPOST: Re: UNION & MINUS - strange work together at different situation
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
This message was cancelled from within The Unacanceller's glorious new software, Lotus 1-2-3 For Rogue Cancellers. Received on Thu Jan 24 2002 - 23:56:57 CST