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

Re: subquery with more than one column

From: Raimon Fernandez <coder(at)montx(dot)com>
To: PostgreSQL Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: subquery with more than one column
Date: 2007-07-06 06:11:27
Message-ID: 88C55313-13B2-4F83-8D23-ECD1987D645B@montx.com (view raw or flat)
Thread:
Lists: pgsql-novice
great !!

that's what I was lookingfor ...

I think my brain was empty ...

:)


regards,

rai


On 05/07/2007, at 23:27, Jon Sime wrote:

> Raimon Fernandez wrote:
>> [..moved top-post..]
>> On 05/07/2007, at 21:30, Tom Lane wrote:
>>> Raimon Fernandez <coder(at)montx(dot)com> writes:
>>>> It's not possible to return in a subquery more than one column ?
>>>
>>> Try it like this:
>>>
>>>   SELECT id_intern, (SELECT ROW(referencia, descripcio) FROM  
>>> articles WHERE...
>>>
>>>             regards, tom lane
>>>
> > but I want as a separate columns, like a normal SELECT ...
> >
> >
> > this is what I get:
> >
> > +---------------+
> > | row           |
> > +---------------+
> > | (1,"ref rai") |
> > | (1,ref)       |
> > +---------------+
> >
> >
> > thanks,
> >
> >
> > raimon
>
> Is there something about the nature of the data which prevents you  
> from using a JOIN between these two tables?
>
>     select pb.id_intern, a.referencia, a.descripcio
>     from product_blister pb
>         join articles a on (a.id_intern = pb.id_product_added)
>     where pb.id_product_source = '8';
>
> (Or using a LEFT JOIN if not every record in product_blister is  
> required to have a corresponding record in articles, and you want  
> those records in product_blister to still be returned.)
>
> My apologies if my assumption is incorrect.
>
> -Jon
>
> -- 
> Senior Systems Developer
> Media Matters for America
> http://mediamatters.org/
>



In response to

pgsql-novice by date

Next:From: stephenDate: 2007-07-06 16:13:06
Subject: distinct doesn't work
Previous:From: Sibte AbbasDate: 2007-07-05 21:48:43
Subject: Re: On_error_stop

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