Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vdtBs-006F8c-0k for pgsql-general@arkaria.postgresql.org; Thu, 08 Jan 2026 16:48:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vdtBr-003Hu8-0I for pgsql-general@arkaria.postgresql.org; Thu, 08 Jan 2026 16:48:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vdtBq-003Htz-2M for pgsql-general@lists.postgresql.org; Thu, 08 Jan 2026 16:48:51 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vdtBp-004v32-2P for pgsql-general@postgresql.org; Thu, 08 Jan 2026 16:48:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 608Gml6x1971487; Thu, 8 Jan 2026 11:48:47 -0500 From: Tom Lane To: Rich Shepard cc: pgsql-general@postgresql.org Subject: Re: Not seeing script error In-reply-to: <72d71614-3fa0-1a27-c271-a83ee759941a@appl-ecosys.com> References: <72d71614-3fa0-1a27-c271-a83ee759941a@appl-ecosys.com> Comments: In-reply-to Rich Shepard message dated "Thu, 08 Jan 2026 08:43:23 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1971485.1767890927.1@sss.pgh.pa.us> Date: Thu, 08 Jan 2026 11:48:47 -0500 Message-ID: <1971486.1767890927@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Rich Shepard writes: > The script: > select p.person_nbr, p.fname, p.lname, p.job_title, p.direct_phone, p.email, > c.company_nbr, c.company_name, c.industry > from people as p > inner join companies as c on p.company_nbr = c.company_nbr > where p.email is not null and > industry = 'Chemicals' or > industry = 'Energy' or > industry = 'Food processor' or > industry = 'Manufacturing' or > industry = 'Maritime' or > industry = 'Transportation' or > industry = 'Wood products' > group by p.person_nbr, c.company_nbr > order by p.person_nbr; > The where condition, `p.email is not null' is not working; the results > include rows where email is null while all other columns are okay. > I had that condition following the industry conditions but that makes no > difference. > What have I missed? AND binds more tightly than OR. I think you meant where p.email is not null and (industry = 'Chemicals' or industry = 'Energy' or industry = 'Food processor' or industry = 'Manufacturing' or industry = 'Maritime' or industry = 'Transportation' or industry = 'Wood products') BTW, using IN might make this more compact. regards, tom lane