Re: Selecting all variations of job title in a list

2025-11-28 Thread Jacqui Caren
Many years ago I used a weak precedence engine to categorize this form of job title script to a job code. The regexp did not work because we had asst to gen mgr The wpe tokenized the words then relaxed token patterns with other token codes with cumulative context The final token reduction resulted

Re: Selecting all variations of job title in a list

2025-11-28 Thread Bernice Southey
Rich Shepard wrote: > Learning postgres regexp is at the top of my list. It's well worth knowing a few regex tricks and they're surprisingly easy to remember. I find these the most useful for ad hoc queries. '|' for or as mentioned '()' if you want to check part of an expression eg '(abc|xyz)pqr

Re: Selecting all variations of job title in a list

2025-11-26 Thread Bryan Sayer
I am not very skilled at Postgresql specifically, but when I was doing SQL in another environment I would just do select distinct (or unique) jobtitle usually getting a count of how many times each title occurred. Then I would create a mapping to standardize the the job titles. *Bryan Sayer*

Re: Selecting all variations of job title in a list

2025-11-26 Thread Rich Shepard
On Wed, 26 Nov 2025, David G. Johnston wrote: I was using this tool a while back when I was doing heavy regex work. https://www.regexbuddy.com/ Keep in mind the native flavor of regex in PostgreSQL is TCL, not Perl. But I’d still say regexp is not the best solution here - unless you encapsula

Re: Selecting all variations of job title in a list

2025-11-26 Thread Rich Shepard
On Wed, 26 Nov 2025, Vincent Veyron wrote: https://perldoc.perl.org/perlre Read the first few pages and you'll be good to go. Thanks, Vincent. Rich

Re: Selecting all variations of job title in a list

2025-11-26 Thread David G. Johnston
On Wednesday, November 26, 2025, Vincent Veyron wrote: > On Wed, 26 Nov 2025 07:10:16 -0800 (PST) > Rich Shepard wrote: > > > > > Learning postgres regexp is at the top of my list. > > > > https://perldoc.perl.org/perlre > > Read the first few pages and you'll be good to go. > I was using this

Re: Selecting all variations of job title in a list

2025-11-26 Thread Vincent Veyron
On Wed, 26 Nov 2025 07:10:16 -0800 (PST) Rich Shepard wrote: > > Learning postgres regexp is at the top of my list. > https://perldoc.perl.org/perlre Read the first few pages and you'll be good to go. -- Bien à vous, Vincent Veyron https://marica.f

Re: Selecting all variations of job title in a list

2025-11-26 Thread Rich Shepard
On Wed, 26 Nov 2025, Vincent Veyron wrote: 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.po

Re: Selecting all variations of job title in a list

2025-11-26 Thread Vincent Veyron
On Tue, 25 Nov 2025 08:33:07 -0800 (PST) Rich Shepard 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 varieti

Re: Selecting all variations of job title in a list

2025-11-25 Thread David G. Johnston
On Tuesday, November 25, 2025, Rich Shepard 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.' > Suggest encoding that knowledge in a table then using normal joins and filter

Re: Selecting all variations of job title in a list

2025-11-25 Thread Adrian Klaver
On 11/25/25 12:53, Rich Shepard wrote: On Tue, 25 Nov 2025, Adrian Klaver wrote: You will need to be clearer about what you want. If it is to fetch titles with Mgr in the name then it would be simple: select * from people_table where title ilike '%mgr%'; If it is something more selective you

Re: Selecting all variations of job title in a list

2025-11-25 Thread Rich Shepard
On Tue, 25 Nov 2025, Adrian Klaver wrote: You will need to be clearer about what you want. If it is to fetch titles with Mgr in the name then it would be simple: select * from people_table where title ilike '%mgr%'; If it is something more selective you will need to provide a more detailed e

Re: Selecting all variations of job title in a list

2025-11-25 Thread Adrian Klaver
On 11/25/25 11:08, Rich Shepard wrote: On Tue, 25 Nov 2025, Adrian Klaver wrote: Something like?: select 'Env mgr.' ilike  ANY(ARRAY['Asst Gen Mgr.', 'Env Mgr.', 'Gen Mgr.', 'Mgr.','Plant Mgr.']); Adrian, Hadn't thought of this. Your, and Ron's, answers taught me that the answer to my que

Re: Selecting all variations of job title in a list

2025-11-25 Thread Rich Shepard
On Tue, 25 Nov 2025, Ron Johnson wrote: Failed clarity on my part. The "OR clauses" are within the regex string. Ron, That's okay. Note that The Relational Way of doing this is for everyone to have title_code in their "person" record, and the "title" table will have, in addition to the tit

Re: Selecting all variations of job title in a list

2025-11-25 Thread Ron Johnson
On Tue, Nov 25, 2025 at 2:05 PM Rich Shepard wrote: > On Tue, 25 Nov 2025, Ron Johnson wrote: > > > Maybe regex_match() with a bunch of OR clauses. > > > > In bash, I'd do something like: > > grep -E ' ^Asst Gen Mgr.*|^Env Mgr.*|^Gen Mgr.*|^Mgr.*|^Plant Mgr..*' > > foo.txt > > Ron, > > I've not u

Re: Selecting all variations of job title in a list

2025-11-25 Thread Rich Shepard
On Tue, 25 Nov 2025, Adrian Klaver wrote: Something like?: select 'Env mgr.' ilike ANY(ARRAY['Asst Gen Mgr.', 'Env Mgr.', 'Gen Mgr.', 'Mgr.','Plant Mgr.']); Adrian, Hadn't thought of this. Your, and Ron's, answers taught me that the answer to my question is 'no, there is no shortcut.' :-)

Re: Selecting all variations of job title in a list

2025-11-25 Thread Rich Shepard
On Tue, 25 Nov 2025, Ron Johnson wrote: Maybe regex_match() with a bunch of OR clauses. In bash, I'd do something like: grep -E ' ^Asst Gen Mgr.*|^Env Mgr.*|^Gen Mgr.*|^Mgr.*|^Plant Mgr..*' foo.txt Ron, I've not used regex in postgres before, only in emacs and small languages. So I'll learn

Re: Selecting all variations of job title in a list

2025-11-25 Thread Adrian Klaver
On 11/25/25 08:33, Rich Shepard 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 u

Re: Selecting all variations of job title in a list

2025-11-25 Thread Ron Johnson
On Tue, Nov 25, 2025 at 11:33 AM Rich Shepard 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 kno

Selecting all variations of job title in a list

2025-11-25 Thread Rich Shepard
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 accept