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 1j4gpX-0003Ms-TB for pgsql-novice@arkaria.postgresql.org; Thu, 20 Feb 2020 08:05:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j4gpW-000415-9E for pgsql-novice@arkaria.postgresql.org; Thu, 20 Feb 2020 08:05:06 +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 1j4gpV-00040y-Up for pgsql-novice@lists.postgresql.org; Thu, 20 Feb 2020 08:05:06 +0000 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j4gpT-0007yy-7p for pgsql-novice@postgresql.org; Thu, 20 Feb 2020 08:05:05 +0000 Received: by mail-qt1-x834.google.com with SMTP id g21so2250096qtq.10 for ; Thu, 20 Feb 2020 00:05:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:subject:message-id:date:to :mime-version; bh=DNcIr8pYc1K/zOHs6n0RGc0AzDU6BACeb2S1eub+HLA=; b=njwsOpphST27dhM4H/1qQMZAHdppebv0/GWOj1j8/9B4z7+B27hD0a1nyYnsznGFE7 rbsygJpod1MeQebhvoDRfpPsI3vuLO3Hc6sX+J7Ik4rCQ8h6k+REZgSvp4Ei9SbyS6As 7CMikhiIUSvyEiLPVsCWQyszQ2yMooCoIA6PoSv6knWgTliKlVZEzCSF5Yx4jYb6Ci2b 3YWRNh5ZP4iBAf5b8h8NaBvtdPdlaKFzZWi4H2qq08sbDPUmL5rm8JkH5/fl1nAM8NYA 1UXu+jmEkhS5iMTPXCuMbx4x8j3qz+moidUk+7cJjt6WZD4oEkmYJ4b7voc6Mc8suplP 1F4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:subject :message-id:date:to:mime-version; bh=DNcIr8pYc1K/zOHs6n0RGc0AzDU6BACeb2S1eub+HLA=; b=LEF2ltddMP4QaEM37xlJiDNa53CFn4xbYCT2qbYCDDBpZDlqRR6jcmA9GOVstEtjqS rzRBc4QLneHv1wc8m9PMf7AGPbH3cFUgjB5oB0/fqzCtJ+QML7CUD1itPANgEDyhX2Fi TjARdjsRQFa8dChP3VrGoHIESewE3LovKmLkJvYlJ/2e3qmgufgVPecWkd0lzsc41om8 h+VHJGiRbTx1AlImfZN6/6OTt7bWWH7AqmnZePks9zGOFVxYkKwZF7DPmZ9SDrkjCZO+ zAzv1TFQ9SZlT6hPBKr6n5d/zSsdrDgtYlK+W4BDZKkif9RpJP034/1BcVDaZMEvNLad BFqw== X-Gm-Message-State: APjAAAV2K2prXxEyDjY7N9P9c2HdvC8AUeq1UBICxDHR/HjuY5zENEfh 4PeaHCUhSmFdQDMkpYjt6loAYgJX X-Google-Smtp-Source: APXvYqzZ3eCx+iXdJPq4A6oMRX2Z/4eoDZO3m9DpbcBUnHxBtmCqgOS4sf5BYuyfB6k6S9Ferqj4SQ== X-Received: by 2002:ac8:c4f:: with SMTP id l15mr25272588qti.177.1582185900738; Thu, 20 Feb 2020 00:05:00 -0800 (PST) Received: from [192.168.1.4] (pints.com. [206.248.184.17]) by smtp.gmail.com with ESMTPSA id k11sm1363150qti.68.2020.02.20.00.04.59 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Feb 2020 00:05:00 -0800 (PST) From: "Bee.Lists" Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Outer Right Join? Message-Id: <8BE08FFD-68C7-45D9-979D-8249AC502BD3@gmail.com> Date: Thu, 20 Feb 2020 03:04:59 -0500 To: Submit Postgresql Novice Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) X-Mailer: Apple Mail (2.3124) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I=E2=80=99m looking for a three-table join. The SQL that I have isn=E2=80= =99t working. companies table - list of companies products table - list of products sold by those companies contracts table - list of companies that hold ad contracts I need to ask: "Show me the queried product (i.e.: Screwdriver) listings with their = company names that DO NOT have contracts" SELECT DISTINCT ON ("listings"."product")=20 "listings"."product", "companies"."name"=20 FROM "listings"=20 RIGHT OUTER JOIN "contracts" ON ("contracts"."companyid" =3D = "listings"."companyid")=20 LEFT JOIN "companies" ON ("companies"."scid" =3D = "listings"."companyid")=20 WHERE (("listings"."product" ILIKE '%screwdriver%' ESCAPE '\'))=20 The result works without the RIGHT OUTER JOIN in there. When the RIGHT = OUTER JOIN is in there, I get a hitlist of zero. Currently I have no = contracts in that table, so those two queries should be the same. They = are not. =20 To repeat, I want any company=E2=80=99s products that are in the = contracts table, to not show up. =E2=80=9Cproducts with no contract=E2=80= =9D. =20 Any inside as to how I can get this to work, appreciated. Cheers, Bee