Actually Solved! Was: (Return t/f on existence of a join)
В списке pgsql-general по дате отправления:
| От | Madison Kelly |
|---|---|
| Тема | Actually Solved! Was: (Return t/f on existence of a join) |
| Дата | |
| Msg-id | 46F43324.50207@alteeve.com обсуждение исходный текст |
| Ответ на | Wait, not solved... Was (Return t/f on existence of a join) (Madison Kelly <linux@alteeve.com>) |
| Список | pgsql-general |
Madison Kelly wrote:
> 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
I'm sorry for all the line noise, but I like to post my solutions "for
the record".
Reading up a bit more of the JOIN types I was finally able to get all
rows in 'foo' returned just once with a t/f depending if a given
baz_bar_id exists. The query is:
(Where '2' is the 'baz_bar_id' I am checking on)
SELECT
f.foo_id,
f.foo_name,
CASE z.baz_foo_id
WHEN 2
THEN TRUE
ELSE FALSE
END
FROM foo f
LEFT JOIN baz z
ON f.foo_id=z.baz_foo_id
AND z.baz_bar_id=2;
Thanks again, both of you!
Madi
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера