From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Dave Hollenbeck <dave(at)fremenworks(dot)org> |
Cc: | pgsql-general(at)hub(dot)org, dave(at)moby5(dot)fremenworks(dot)org |
Subject: | Re: arrays and subselects |
Date: | 2000-09-20 17:56:12 |
Message-ID: | Pine.BSF.4.10.10009201045280.57382-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 20 Sep 2000, Dave Hollenbeck wrote:
> insert into testme1 values(1,'{1,2,3}');
> insert into testme1 values(2,'{4,5,6}');
> insert into testme2 values(10,5);
>
> select key2 from testme2 where data2 in (select data1 from testme1
> where key1 = 2);
>
> Generates the following error
>
> ERROR: Unable to identify an operator '=' for types 'int2' and '_int2'
> You will have to retype this query using an explicit cast
>
> Although I could name the array elements individually, this would be
> most useful when the length of the array is variable.
I'd suggest looking at the array package in contrib which includes
functions/operators for element-in-array. Then you can use a simple
join or exists to do the query (also avoiding potential ugliness in using
in anyway).
The other option of course to make an int2=_int2 operator which is the
element-in-array, which would probably let you use the above syntax.
However, I'm not sure that's a good default. This is a problem with
arrays, are they data or are they a short form for rows of that value
type?
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2000-09-20 17:58:26 | Re: syntax errors in initdb for NT install of pgsql 7.0 |
Previous Message | Peter Eisentraut | 2000-09-20 17:52:51 | Re: postgres-user <-> unix user |