Re: problem with update from subselect - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: problem with update from subselect
Date
Msg-id 20020501095436.Q24344-100000@megazone23.bigpanda.com
Whole thread Raw
In response to problem with update from subselect  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
List pgsql-sql
On Wed, 1 May 2002, Gary Stainburn wrote:

> Hi all, using the schema described below, I want to be able to update each
> arrival time from departure times and trip lengths.
>
> However the update fails because the subselect returns all three answers.
>
> How would I correct the update to make it work
>
> update trip set trip_arrive = (select t.trip_depart + r.route_time
>   from route r, trip t where r.routeid = t.trip_route);

Do you really want to join with another "trip" in the subselect?

I think you probably want something like:
update trip set trip_arrive = (select trip.trip_depart + r.route_timefrom route r where r.routeid=trip.trip_route);



pgsql-sql by date:

Previous
From: "Travis Hoyt"
Date:
Subject: Problems returning multiple columns
Next
From: Joe Conway
Date:
Subject: Re: problem with update from subselect