Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: AND or UNION
In article <5e1cr3$klb_at_ustsu10.ust.hk>,
Wong Chung Yin <cscywong_at_ug.cs.ust.hk> wrote:
>Mark Rosenbaum (mjr_at_netcom.com) wrote:
>: >: Which one is more efficient?
>: > 1. select * from empdemo where empdemo = 0 or empdemo = 1;
>: >
>: >: 2. select * from empdemo where empdemo = 0
>: >: union
>: >: select * from empdemo where empdemo = 1;
>: >
>: I believe that a union becomes a union all and then a sort to
>: eliminate dups. Not only is the second query not going to give
>: you the right answer it will be slow doing it. If you would
>
>I don't know why the second query cannot give me the right answer.
>Could u mind explaining more detail?
Sorry, I did not see the change from and to or. These should be the same. I still think that the union will be slower due to the sort and a union all will give dups. Have you had a chance to test it yet?
mjr Received on Fri Feb 14 1997 - 00:00:00 CST