| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Not seeing script error |
| Date: | 2026-01-08 16:48:47 |
| Message-ID: | 1971486.1767890927@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Rich Shepard <rshepard(at)appl-ecosys(dot)com> 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ron Johnson | 2026-01-08 17:03:29 | Re: Not seeing script error |
| Previous Message | Rich Shepard | 2026-01-08 16:43:23 | Not seeing script error |