| From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
|---|---|
| To: | Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk> |
| Cc: | <pgsql-sql(at)postgresql(dot)org> |
| Subject: | Re: problem with update from subselect |
| Date: | 2002-05-01 16:55:47 |
| Message-ID: | 20020501095436.Q24344-100000@megazone23.bigpanda.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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_time
from route r where r.routeid=trip.trip_route);
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joe Conway | 2002-05-01 17:09:11 | Re: problem with update from subselect |
| Previous Message | Travis Hoyt | 2002-05-01 16:51:29 | Problems returning multiple columns |