pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vernon Wu <vernonw@gatewaytech.com>
To: Christoph Haller <ch@rodos.fzk.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: Can I search for an array in csf?
Date: Tue, 22 Oct 2002 04:07:51 -0700
Message-ID: <HFONZXTRQRQBWVCA3YGEMJ7108PJ4Y.3db53187@kimiko> (raw)
In-Reply-To: <3DB5498E.A12E8BF1@rodos.fzk.de>

Hi, Christoph,

Thanks for reminding me regular expression. 

The background of my question is about attributes of one element, say hobby for example. Different people have 
different hobbies. Inside of the application, hobbies are denoted in various characters. The selection I mentioned in the 
original mail refers to finding people who have certain hobbies in the case.

I think regular expression is the most effective way for the usage.

Thanks again.

Vernon


10/22/2002 5:50:22 AM, Christoph Haller <ch@rodos.fzk.de> wrote:

>>
>> I thought I had made my case clear. Let me rephrase it.
>>
>> I have a character array, {'a', 'b', 'c', 'd'} for example. And this
>array is stored in a DB table field as a string
>of "a,b,c,d".
>> Now, I want to find out whether the table field, or array, contains
>any character set of {'c', 'e', 'h'}. My question
> is
>> whether SQL statement is appliable for this selection, or the data has
>been retrieved and process in the application
>> level.
>>
>> I hope I make th case clear this time.
>>
>Ok, now I see.
>Maybe the Postgres POSIX Regular Expressions are what you are looking
>for.
>Suppose your array "a,b,c,d" is stored into a table field of type
>character,
>character varying or text.
>Then, if you are searching for all entries containing a 'c', 'e',  or
>'h' character
>your SELECT statement would look like
>
>SELECT col1, col2, ... FROM table1 WHERE arrayfield ~ '[ceh]' ;
>
>Still not sure if you mean a sequence like "c,e,h" on the other hand.
>Then
>SELECT col1, col2, ... FROM table1 WHERE arrayfield ~ 'c,e,h' ;
>should do the trick - as long as the order of characters is identical.
>A sequence of "e,c,h" would not show up, of course.
>
>Regular Expressions are far more powerful than these two examples can
>show.
>Refer to the related chapter in the documentation.
>I hope this helps more than the other replies you've received telling
>you
>'Learn about DB-design first'.
>
>Regards, Christoph
>
>






view thread (9+ messages)  latest in thread

Message-ID: <HFONZXTRQRQBWVCA3YGEMJ7108PJ4Y.3db53187@kimiko>
Permalink:  ../HFONZXTRQRQBWVCA3YGEMJ7108PJ4Y.3db53187@kimiko/
Also on:    postgresql.org/message-id/HFONZXTRQRQBWVCA3YGEMJ7108PJ4Y.3db53187@kimiko

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: vernonw@gatewaytech.com, ch@rodos.fzk.de
  Subject: Re: Can I search for an array in csf?
  In-Reply-To: <HFONZXTRQRQBWVCA3YGEMJ7108PJ4Y.3db53187@kimiko>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox