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 1vdtQI-006Ipd-2X for pgsql-general@arkaria.postgresql.org; Thu, 08 Jan 2026 17:03:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vdtQG-003PoV-0b for pgsql-general@arkaria.postgresql.org; Thu, 08 Jan 2026 17:03:44 +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 1vdtQF-003PoN-2Y for pgsql-general@lists.postgresql.org; Thu, 08 Jan 2026 17:03:44 +0000 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vdtQF-004vAk-0U for pgsql-general@postgresql.org; Thu, 08 Jan 2026 17:03:43 +0000 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-3f0d1a39cabso2392997fac.3 for ; Thu, 08 Jan 2026 09:03:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767891821; x=1768496621; darn=postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=CWG3wlrv7/Am6pbREnarcDLQliDJyRuQfRpD5nN0qdk=; b=NNEE8oNgx3SOTAocfRmvMcWubAhFS/uYzRjMNaT+gxuShueDyA2hlDMy3pGhvcsr0C SspJ9wW1qki1HnT0sEXSHtCQZg93GlIEqWZwcB7/VMIwAFZMPLAtH6/BIBncV0YkwMAr bD9/AcGaaRR/VpQtOJr3OeoF84q7fT76RcMp3u62UhnthDb4QNjTTuf4f9wwiLiLxTFh KIwo6Q1Vm2mqlELtJbNoGb+JYDKEbzAhMwya+ihbRNlpD0LSyg6don3nnkNN4yBepzuD 0y+7tzBL6sxm6OXSzlpQZU5sq7GSiFVGlAx7M4d2maC5BTHQm6zXHRwsluYuAw9RjXjm fHUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767891821; x=1768496621; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CWG3wlrv7/Am6pbREnarcDLQliDJyRuQfRpD5nN0qdk=; b=ZfhU3R86OLn5kIXKZiRAKKZYGlYojBJ2cLweyUCdA9O2SikV9hcKNzgWJhQn236iH3 uFZXUPrVSf5xH2gwzIFmd/SQQameX1GfkpgKEfyIeyk0zBaS6k9LUNAz3iAwaFVctTcY WS0isaBROtA3X0wehhPiGVrOdEn8ampNAogr8oUFKr0PmwmdUilAqNfRsMgnw2R0ZDnX HcMC1tMKQ4gzACksHEGG5H78Vso8+g0seK6nio8Nt3cxwkhO0RaANVI0vz3TGaL4H7RF EgdQ6xDu84atjloxoH3FEsKDz+Gevht5hxlRGYCYNzlB0YHt6JAlDQClSoVNSZMCBg5g Us1Q== X-Gm-Message-State: AOJu0YxJnq7hWysvkuEhMnsvrkl04+XRyub275kTU4oCC+Az00VAFAKz Mp5B3CtiD+H5ubAhPSKpDiF0otsZo5sq6EovobSj/80vt6QXFYi4mB+x5wnlU/1/G0bcvE6z2fA VpTXNF67B/+ZPea5dizXaGotRVZI/yypRlw== X-Gm-Gg: AY/fxX5Yv3Xi6py6uo96s6WwU8UypH1bMhMEAWy6LOjudOwGl4c/1/6gmv50lbDiW9I DCPcCwKnHpTIZvk63umq45IL9s07+/y9zZT2nORt0xQdEOmXL46Krai3LZsfUmqWC+1/oy4pTLE Bb43AcwmTHm/jx2/Y0nOIO+Rna+PR0AMZL4DtXTp35O+tAy9g/dZCmx+70aPgv1/oKkA+hPhHED wPdkzfZ53UEOMoFzsY45FLrYvE4vg2kYV0kn1LfbrsTIzw3v0oB/KnQ7vcz2SrxjOaAH2lT X-Google-Smtp-Source: AGHT+IEyrQIbsxT4UA4QgsFql5rFn0sJrnms5KFHGwjUOtTXM6TE68Z2drYY0w04NRvxAbFCxeI8v4RtKHTMe/DsdqQ= X-Received: by 2002:a05:6820:f002:b0:65d:a79:568b with SMTP id 006d021491bc7-65f54eebcccmr2671099eaf.34.1767891821159; Thu, 08 Jan 2026 09:03:41 -0800 (PST) MIME-Version: 1.0 References: <72d71614-3fa0-1a27-c271-a83ee759941a@appl-ecosys.com> <1971486.1767890927@sss.pgh.pa.us> In-Reply-To: <1971486.1767890927@sss.pgh.pa.us> From: Ron Johnson Date: Thu, 8 Jan 2026 12:03:29 -0500 X-Gm-Features: AZwV_QhCo1qVz95o-C9w2uw8jTEoc5qxOz8qfzN3NyN54PCLDsXJDdyXmHymYlg Message-ID: Subject: Re: Not seeing script error To: pgsql-general Content-Type: multipart/alternative; boundary="0000000000000068370647e36418" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000000068370647e36418 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jan 8, 2026 at 11:48=E2=80=AFAM Tom Lane wrote: > 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 =3D c.company_nbr > > where p.email is not null and > > industry =3D 'Chemicals' or > > industry =3D 'Energy' or > > industry =3D 'Food processor' or > > industry =3D 'Manufacturing' or > > industry =3D 'Maritime' or > > industry =3D 'Transportation' or > > industry =3D '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 n= o > > difference. > > > What have I missed? > > AND binds more tightly than OR. I think you meant > > where p.email is not null and > (industry =3D 'Chemicals' or > industry =3D 'Energy' or > industry =3D 'Food processor' or > industry =3D 'Manufacturing' or > industry =3D 'Maritime' or > industry =3D 'Transportation' or > industry =3D 'Wood products') > > BTW, using IN might make this more compact. > While missing parentheses would not break the logic. --=20 Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --0000000000000068370647e36418 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Jan 8, 2026 at 11:48=E2=80=AFAM T= om Lane <tgl@sss.pgh.pa.us> = wrote:
Rich Shepard <rshepard@appl-ecosys.com> wr= ites:
> The script:
> select p.person_nbr, p.fname, p.lname, p.job_title, p.direct_phone, p.= email,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0c.company_nbr, c.company_name, c.indu= stry
> from people as p
> inner join companies as c on p.company_nbr =3D c.company_nbr
> where p.email is not null and
> industry =3D 'Chemicals' or
> industry =3D 'Energy' or
> industry =3D 'Food processor' or
> industry =3D 'Manufacturing' or
> industry =3D 'Maritime' or
> industry =3D 'Transportation' or
> industry =3D '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 res= ults
> 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.=C2=A0 I think you meant

where p.email is not null and
(industry =3D 'Chemicals' or
industry =3D 'Energy' or
industry =3D 'Food processor' or
industry =3D 'Manufacturing' or
industry =3D 'Maritime' or
industry =3D 'Transportation' or
industry =3D 'Wood products')

BTW, using IN might make this more compact.

=
While missing=C2=A0parentheses would not break the logic.
--
Death to <Redacted&g= t;, and butter sauce.
Don't boil me, I'm still alive.
<= div><Redacted> lobster!
--0000000000000068370647e36418--