public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Rich Shepard <[email protected]>
Cc: [email protected]
Subject: Re: Not seeing script error
Date: Thu, 08 Jan 2026 11:48:47 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
Rich Shepard <[email protected]> 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
view thread (3+ messages) latest in thread
reply
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Not seeing script error
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox