Re: select from pipe-delimited field

From: David Fetter <david(at)fetter(dot)org>
To: san man <neelakash21(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org
Subject: Re: select from pipe-delimited field
Date: 2010-08-23 22:48:15
Message-ID: 20100823224815.GB16239@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

On Mon, Aug 23, 2010 at 05:44:09PM -0500, san man wrote:
> Hello all,
>
> I am trying to do a SELECT operation with a WHERE condition. However, the
> column with which I am trying to do the comparison has several values which
> are pipe-delimited. I want to return a match(true) if the WHERE condition
> matches any of the bar-delimited values.

You'll want to normalize this table into two or more tables, at some
point.

> For example, SELECT id WHERE synonyms = 'word';
>
> Here synonyms is a pipe-delimited field and I want to match "word" with any
> of the values of the synonyms fields.

Try the LIKE function.

http://www.postgresql.org/docs/current/static/functions-matching.html#FUNCTIONS-LIKE

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Arjen Nienhuis 2010-08-23 22:59:40 Re: select from pipe-delimited field
Previous Message san man 2010-08-23 22:44:09 select from pipe-delimited field

Browse pgsql-novice by date

  From Date Subject
Next Message Arjen Nienhuis 2010-08-23 22:59:40 Re: select from pipe-delimited field
Previous Message san man 2010-08-23 22:44:09 select from pipe-delimited field