Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iC0fm-0007UN-KT for pgsql-general@arkaria.postgresql.org; Sun, 22 Sep 2019 12:09:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iC0fl-0005HF-8O for pgsql-general@arkaria.postgresql.org; Sun, 22 Sep 2019 12:09:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iC0fk-0005Gl-Sy for pgsql-general@lists.postgresql.org; Sun, 22 Sep 2019 12:09:00 +0000 Received: from jan-kohnert.de ([2001:4ba0:fff1:c3::1]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iC0fi-0005qF-So for pgsql-general@lists.postgresql.org; Sun, 22 Sep 2019 12:09:00 +0000 X-Virus-Scanned: amavisd-new at jan-kohnert.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jan-kohnert.de; s=20191; t=1569154135; bh=vWYH3d+cY+Ly05zrCDxTHvjc1m2uvqLhGAqHgBr4pH4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=flSXbuT8SD3hiRuSWkglh4L9/a5YQEp2egFk/03MJQquEmvkNBXLJ7Sk5KP1vrkoA BxPD5bgD28eBSbEmAGdsX2Q6poNqTLj1hTIOhpZoInEMMFZ05Ur11ivSHb9uUdkjyW fJ3e7PihRfB6TPI1tyHLfGf9hIjkkPTzj6lrawZSOF3HEQZm3xLFe+xIxBGV9FCd1g +bOiqj4t3TQL8H7GHqZwtsuGvob1fdQOyLx/z44M3dX8qZ8Wf3JIzrAWro5NvN9Thd lwwMzQn6HV9fNpnjcNFSjtnaMjhMcoICx1zJn6pvx+TmzFZjoUDM0J4keH03bk9lBJ 5imdG3I+c8uUQ== Received: from kohni-mobil.localnet (p4FD8BDB7.dip0.t-ipconnect.de [79.216.189.183]) by b079.blue.fastwebserver.de (Postfix) with ESMTPSA id 5E74B400AFECC for ; Sun, 22 Sep 2019 14:08:54 +0200 (CEST) From: Jan Kohnert To: pgsql-general@lists.postgresql.org Subject: Re: Extend inner join to fetch not yet connected rows also Date: Sun, 22 Sep 2019 14:08:53 +0200 Message-ID: <1780284.qfRisySgFs@kohni-mobil> In-Reply-To: <7B8CBECF-09A5-492B-9E22-EDD7B0DBD469@zeit.io> References: <7B8CBECF-09A5-492B-9E22-EDD7B0DBD469@zeit.io> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hey, Am Sonntag, 22. September 2019, 13:21:46 CEST schrieb Arup Rakshit: > I have craftsmanships table which has (id, name) and users table (id, email, > ..). When a user has some craftsmanships, they are stored inside the > contractor_skills(user_id, craftsmanship_id, id) table. [...] > But I want to list all craftsmanships and has column should have `t` when > user_id #8 has it, else `f`. How can I extend this query? 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; -- MfG Jan