Wait, not solved... Was (Return t/f on existence of a join)

From: Madison Kelly <linux(at)alteeve(dot)com>
To: Madison Kelly <linux(at)alteeve(dot)com>
Cc: Erik Jones <erik(at)myemma(dot)com>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>, jsime(at)mediamatters(dot)org
Subject: Wait, not solved... Was (Return t/f on existence of a join)
Date: 2007-09-21 20:38:23
Message-ID: 46F42BBF.3070104@alteeve.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Madison Kelly wrote:
> Thanks to both of you, Erik and Jon!
>
> I had to tweak your two replies to get what I wanted (all 'foo' rows
> returned, was only getting ones with a match in 'baz'). You two sent me
> on the right path though and I was able to work out the rest using the
> PgSQL docs on 'CASE' and 'JOIN'.
>
> Here is the working query (where 'bar_id'=2):
>
> SELECT
> CASE z.baz_bar_id
> WHEN 2
> THEN TRUE
> ELSE FALSE
> END AS tf_col,
> f.foo_id
> FROM foo f
> LEFT OUTER JOIN baz z
> ON (f.foo_id=z.baz_foo_id)
> LEFT OUTER JOIN bar b
> ON (b.bar_id=z.baz_bar_id)
> AND
> b.bar_id=2;
>
> Thanks kindly to both! I honestly didn't expect to work this out
> before then end of the day. Cool!
>
> Madi

Doh!

It's returning a row from 'foo' for every entry in baz that has an
entry pointing to foo (possibly same problem with each pointer to an
entry in bar, not sure yet). The 'true/false' part is working though...

Back to reading. *sigh* :)

Madi

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Madison Kelly 2007-09-21 21:09:56 Actually Solved! Was: (Return t/f on existence of a join)
Previous Message Madison Kelly 2007-09-21 20:32:51 Solved! Was (Return t/f on existence of a join)