Re: Selecting all variations of job title in a list - Mailing list pgsql-general

From Vincent Veyron
Subject Re: Selecting all variations of job title in a list
Date
Msg-id 20251126154844.e6e3d5c7f476cc966fc201f4@wanadoo.fr
Whole thread Raw
In response to Selecting all variations of job title in a list  (Rich Shepard <rshepard@appl-ecosys.com>)
Responses Re: Selecting all variations of job title in a list
List pgsql-general
On Tue, 25 Nov 2025 08:33:07 -0800 (PST)
Rich Shepard <rshepard@appl-ecosys.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



pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject: Re: Question on PostgreSQL Table Partitioning – Performance of Queries That Do Not Use the Partition Key
Next
From: Rich Shepard
Date:
Subject: Re: Selecting all variations of job title in a list