Skip site navigation (1) Skip section navigation (2)

Re: Querying a list field against another list

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Aarni Ruuhimäki <aarni(at)kymi(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Querying a list field against another list
Date: 2004-11-26 15:53:56
Message-ID: 20041126155356.GB26221@wolff.to (view raw or flat)
Thread:
Lists: pgsql-novice
On Fri, Nov 26, 2004 at 15:52:31 +0200,
  Aarni Ruuhimäki <aarni(at)kymi(dot)com> wrote:
> Hi people,
> 
> This is not quite a pg question, but any suggestions are most welcome.
> 
> How can one query a list of values against a db field that contains a list of 
> values ?

You really want to redesign your database so that the foo_id da_list
relationship only has one foo_id da_list item per row.

> 
> 
> Table foo
> 
> foo_id | foo_name | da_list
> --------------------------------------
> 1 | x | 1,2,3,4,5
> 2 | y | 1,4,5
> 3 | z | 4,5,11
> 4 | xyz | 14,15,33
> 
> As a result from another query I have parameter bar = '1,4' and want to find 
> all rows from foo where da_list contains '1' or '4'. So loop over bar to loop 
> over da_list in foo ?

In response to

pgsql-novice by date

Next:From: Stephan SzaboDate: 2004-11-26 16:52:52
Subject: Re: problem with memory allocation
Previous:From: Bruno Wolff IIIDate: 2004-11-26 15:04:52
Subject: Re: Converting file -Invalid data format on input DATE

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group