Re: extracting words

From: Tarlika Elisabeth Schmitz <postgresql(at)numerixtechnology(dot)de>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tarlika Elisabeth Schmitz <postgresql(at)numerixtechnology(dot)de>, pgsql-sql(at)postgresql(dot)org
Subject: Re: extracting words
Date: 2008-04-23 14:57:35
Message-ID: 20080423155735.2755b5c7@dick.coachhouse
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 23 Apr 2008 09:13:03 -0400
Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:

> Tarlika Elisabeth Schmitz wrote:
>
> > I need to extract the words from department_name and product_name
> > (words are separated by spaces) and get something like:
> >
> > 1 cakes
> > 1 desserts
> > 1 apple
> > 1 crumble
> > 2 cakes
> > 2 desserts
> > 2 cheese
> > 2 cake
> > 3 starters
> > 3 soups
> > 3 french
> > 3 onion
> > 3 soup
>
> regexp_split_to_table is handy (8.3 only):
>
> select pk, regexp_split_to_table(product_name, '[& ]+') from products
> union
> select pk, regexp_split_to_table(dept_name, '[& ]+') from departments;
>
> Add joins as desired.

This is neat!
Unfortunately, on the machine that I need this, we are running 7.4.

--

Best Regards,

Tarlika Elisabeth Schmitz

A: Because it breaks the logical sequence of discussion
Q: Why is top posting bad?

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Nacef LABIDI 2008-04-24 12:59:47 First day of month, last day of month
Previous Message Alvaro Herrera 2008-04-23 13:13:03 Re: extracting words