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

Home -> Community -> Usenet -> c.d.o.misc -> Re: join in SQL

Re: join in SQL

From: Gerard Le Comte <lecomte_at_sns.fr>
Date: 1997/11/17
Message-ID: <34701AE0.7B18@sns.fr>#1/1

tkyte wrote :
> select a.value, c.value
> from a, c
> where a.c_id = c.id
> and not exists ( select NULL
> from B
> where b.c_id = c.id and b.a_id = a.id )
> /
>
> is one way to do it I believe...

A real case could be like that :
(select Man, house from Men(a),Houses(c) : this default house and his other houses (b))

This was exactly :

--
select a.value, c.value
  from a, c
 where a.c_id = c.id
   or exists ( select 'X'   from B
               where b.c_id = c.id and b.a_id = a.id );
--
	Yes, it works. Finally, it was better than an outer join
because, I have other tables like b and creating views for each
is not simple.

	But,.....
I have compared this method ( using the 'exists' function )
with this method :
	I have inserted a row in b : (null, null) so that a can do
the following SQL statement :

--
select a.value, c.value
  from a, b, c
 where a.c_id = c.id
   or ( b.c_id = c.id and b.a_id = a.id );
--

This return the same result but very, very faster. <<<*****************

However this method is not pretty and even if the table, b,
can't contain value (null, null), b contains an extra value.

Has anybody any comments on my speed results
or has others solutions ???

		thanks,

		Gerard Le Comte
Received on Mon Nov 17 1997 - 00:00:00 CST

Original text of this message

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