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

Home -> Community -> Usenet -> comp.databases.theory -> Re: difference between UNION operator and OR in where clause

Re: difference between UNION operator and OR in where clause

From: Bob Badour <bbadour_at_pei.sympatico.ca>
Date: Tue, 10 Jul 2007 11:24:01 -0300
Message-ID: <46939666$0$8827$9a566e8b@news.aliant.net>


David Portas wrote:

> On 10 Jul, 14:39, Mike <gongweig..._at_gmail.com> wrote:
> 

>>tables:
>>1. publication(pubid, title)
>>2. book(pubid, date)
>>3. journal(pubid, date)
>>
>>purpose: find all publication titles for books or journals.
>>
>>solution 1: use set "union"
>>
>>select title
>>from publication, ( (select pubid from book) UNION (select pubid from
>>journal)) bj
>>where publication.pubid = bj.pubid
>>
>>solution 2: use "or" operator in the where clause
>>
>>select title
>>from publication, book, journal
>>where publication.pubid = book.pubid or publication.pubid =
>>journal.pubid
>>
>>This example is taken from some lecture notes about sql. The notes
>>said the solution 2 was wrong.
>>
>>Anyone knows why ?
> 
> Let me pose two more questions for you. What are the keys for each
> table? What is the difference between ALL and DISTINCT?
> 
> If you can answer those questions then you may be on the way to the
> answer you are looking for.

Not really. He really needs to look into the concept of CROSS PRODUCT as it applies to the FROM clause. Received on Tue Jul 10 2007 - 09:24:01 CDT

Original text of this message

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