From: Jan Kohnert <nospam001-lists@jan-kohnert.de>
To: pgsql-general@lists.postgresql.org
Subject: Re: Extend inner join to fetch not yet connected rows also
Date: Sun, 22 Sep 2019 15:25:46 +0200
Message-ID: <1695753.vyHXCZFGd1@kohni-mobil> (raw)
In-Reply-To: <BBC4F372-71F2-46BA-BCF2-CCEB4F7F9F4B@zeit.io>
References: <7B8CBECF-09A5-492B-9E22-EDD7B0DBD469@zeit.io>
<1780284.qfRisySgFs@kohni-mobil>
<BBC4F372-71F2-46BA-BCF2-CCEB4F7F9F4B@zeit.io>
Hi Arup,
Am Sonntag, 22. September 2019, 14:48:20 CEST schrieb Arup Rakshit:
> Hi Jan,
>
> > On 22-Sep-2019, at 5:38 PM, Jan Kohnert <nospam001-lists@jan-kohnert.de>
> > wrote:
> > maybe something like
> >
> > select
> >
> > c.id,
> > c.name,
> > case when cs.user_id = 8 then true else false end as has
> >
> > from craftsmanships c
> > left join contractor_skills cs
> >
> > on cs.craftsmanship_id = c.craftmanship_id;
>
> But this query fetched duplicate data:
yeah, that's possible, since I don't exactly know your data model. If only the
values above are required, you could simply use distinct:
select distinct
c.id,
c.name,
case when cs.user_id = 8 then true else false end as has
from craftsmanships c
left join contractor_skills cs
on cs.craftsmanship_id = c.id
order by
c.id;
--
MfG Jan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: nospam001-lists@jan-kohnert.de
Subject: Re: Extend inner join to fetch not yet connected rows also
In-Reply-To: <1695753.vyHXCZFGd1@kohni-mobil>
References: <7B8CBECF-09A5-492B-9E22-EDD7B0DBD469@zeit.io> <1780284.qfRisySgFs@kohni-mobil> <BBC4F372-71F2-46BA-BCF2-CCEB4F7F9F4B@zeit.io> <1695753.vyHXCZFGd1@kohni-mobil>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox