| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> difference between UNION operator and OR in where clause
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 ?
Thanks ahead. Received on Tue Jul 10 2007 - 08:39:30 CDT
![]() |
![]() |