Re: Insert using a subselect?

From: Jason Tan <jason(at)rebel(dot)rebel(dot)net(dot)au>
To: Francisco Reyes <lists(at)natserv(dot)com>
Cc: Pgsql Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Insert using a subselect?
Date: 2001-09-11 05:22:52
Message-ID: Pine.LNX.3.95.1010911145227.27217H-100000@rebel.rebel.net.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

You need to make it return just one row.
It doenst knwo which value to use in the insert.

Jason

On Tue, 11 Sep 2001, Francisco Reyes wrote:

> On Tue, 11 Sep 2001, Jason Tan wrote:
>
> >
> > On Mon, 10 Sep 2001, Francisco Reyes wrote:
> >
> > > Does PostgreSQL supports doing an insert with a subselect as it's value?
> > > Something like:
> > > insert into hearn_dates (date)
> > > values ((select distinct merge_date from hearn));
> > > The error I am getting is:
> > > ERROR: More than one tuple returned by a subselect used as an expression.
> >
> > Presumably you slect distinct is returing more than one value/tuple.
> >
> > Run it by hand and see what it returns.
>
> drf=# select distinct merge_date from hearn;
> merge_date
> ------------
> 2000-11-17
> 2001-07-10
> 2001-09-07
> (3 rows)
>
> 3 rows on 1 column.
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl
>

--
------------------------------------------------------------------------------
Jason Tan jason(at)rebel(dot)net(dot)au
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."
~Benjamin Franklin, 1759
------------------------------------------------------------------------------

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jason Tan 2001-09-11 05:30:06 Re: Path for pgsql \i option?
Previous Message Francisco Reyes 2001-09-11 04:40:06 Path for pgsql \i option?