| From: | Vincent Veyron <vv(dot)lists(at)wanadoo(dot)fr> |
|---|---|
| To: | pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Selecting all variations of job title in a list |
| Date: | 2025-11-26 14:48:44 |
| Message-ID: | 20251126154844.e6e3d5c7f476cc966fc201f4@wanadoo.fr |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Tue, 25 Nov 2025 08:33:07 -0800 (PST)
Rich Shepard <rshepard(at)appl-ecosys(dot)com> wrote:
> Companies can have slightly different titles for the same job; for example
> (using abbreviations). 'Asst Gen Mgr.', 'Env Mgr,', 'Gen Mgr,'. 'Mgr,',
> 'Plant Mgr.'
>
> I want to select all people table rows that contain these varieties. I know
> the 'like' operator uses '%' as a wildcard, but is not accepted in an 'in'
> list.
>
> Is there a way to use a multicharacter wildcard in an 'in' list?
>
Hi Rich,
As Ron wrote, a regexp would do it, I guess?
SELECT * FROM people WHERE title ~ 'Asst Gen Mgr|Env Mgr|Gen Mgr|Mgr|Plant Mgr';
Although in your example, you would get the same result with just:
SELECT * FROM people WHERE title ~ 'Mgr';
https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-POSIX-REGEXP
--
Bien à vous, Vincent Veyron
https://marica.fr/
Logiciel de suivi des contentieux juridiques, des sinistres d'assurance et des contrats
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Rich Shepard | 2025-11-26 15:10:16 | Re: Selecting all variations of job title in a list |
| Previous Message | Ron Johnson | 2025-11-26 14:16:23 | Re: Question on PostgreSQL Table Partitioning – Performance of Queries That Do Not Use the Partition Key |