Re: subquery with more than one column

From: Jon Sime
Subject: Re: subquery with more than one column
Date: ,
Msg-id: 468D6254.6060501@mediamatters.org
(view: Whole thread, Raw)
In response to: Re: subquery with more than one column  (Raimon Fernandez)
Responses: Re: subquery with more than one column  (Raimon Fernandez)
List: pgsql-novice

Tree view

oid or without oid ...  (Raimon Fernandez, )
 Re: oid or without oid ...  (Sean Davis, )
  Re: oid or without oid ...  (Raimon Fernandez, )
   Re: oid or without oid ...  (Sean Davis, )
    Re: oid or without oid ...  (Raimon Fernandez, )
 subquery with more than one column  (Raimon Fernandez, )
  Re: subquery with more than one column  (Tom Lane, )
   Re: subquery with more than one column  (Raimon Fernandez, )
    Re: subquery with more than one column  (Jon Sime, )
     Re: subquery with more than one column  (Raimon Fernandez, )

Raimon Fernandez wrote:
> [..moved top-post..]
> On 05/07/2007, at 21:30, Tom Lane wrote:
>
>> Raimon Fernandez <> 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/


pgsql-novice by date:

From: "Sibte Abbas"
Date:
Subject: Re: On_error_stop
From: Raimon Fernandez
Date:
Subject: Re: subquery with more than one column