Re: problem with update from subselect

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: problem with update from subselect
Дата
Msg-id 20020501095436.Q24344-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на problem with update from subselect  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
Список 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 по дате отправления:

Предыдущее
От: "Travis Hoyt"
Дата:
Сообщение: Problems returning multiple columns
Следующее
От: Joe Conway
Дата:
Сообщение: Re: problem with update from subselect