Обсуждение: Updating

Поиск
Список
Период
Сортировка

Updating

От
Bob Kruger
Дата:
Thanks for all who assisted with my previous question on grouping.

I would like to do an update of a table with the results of a query on
another.

For example:

table vehcost

id        serial
po        varchar(12)
veh_no        varchar(8)
cost        real
comments    varchar(30)


table vehinfo

id            serial
veh_no        varchar(12)
m_cost        real
...


I would like to take the sum of vehcost.veh_no and update that info to
field vehinfo.m_cost.

So far, I have worked with the following without success:

update vehinfo set m_cost = (select sum(vehcost.cost) from vehcost group by
veh_no) where vehinfo.veh_no = vehcost.veh_no ; 

Any ideas.

Thanks in advance for any assistance.

Regards - Bob Kruger