* Stephan Szabo <sszabo@megazone.bigpanda.com> [100904, 10:39]:
> On Fri, 10 Sep 2004, Ennio-Sr wrote:
> > > > * Stephan Szabo <sszabo@megazone.bigpanda.com> [100904, 07:10]:
> > > > > On Fri, 10 Sep 2004, Ennio-Sr wrote:
> > > > > [ big cut ]
> > >
>
> Well, I'd expect that for large tables the outer join type solution would
> tend to be faster than joining every row to every other row and then using
> a unique step (probably after a sort) to basically remove the ones you
> don't want. If you try different solutions, you can use EXPLAIN ANALYZE to
> compare query plans.
Please forget my previous message: I've just finished trying your
'COALESCE' solution (prior to studying it ;) ) and it seems to work
greatly!
---------
SELECT
t0.a, t0.b, t0.c, COALESCE(t1.d, ' ') as note from foo t0 left OUTER
JOIN foo_d t1 on (t0.has_d = 'Y' AND t0.a=t1.a);
# the result is:
a | b | c | note
---+------+--------+----------------------------------
1 | one | number | is the first natural
2 | two | number | follows 1 in the seq of natural
3 | tree | name | there are various qualities of -
4 | blue | color |
5 | john | person |
(5 rows)
^^^
---------
Perfect, I would say :-)
Thank you again so much indeed, Stephan.
Ennio.
--
[Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo. \\?//
Fa' qualche cosa di cui non sei capace!" (diceva Henry Miller) ] (°|°)
[Why to use Win$ozz (I say) if ... "even a fool can do that. )=(
Do something you aren't good at!" (used to say Henry Miller) ]