Updating

From: Bob Kruger <bkruger(at)mindspring(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Updating
Date: 1999-06-16 17:06:24
Message-ID: 3.0.5.32.19990616120624.007e95e0@mindspring.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


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

Browse pgsql-sql by date

  From Date Subject
Next Message Ravneet Mann 1999-06-16 17:26:34 help needed
Previous Message José Soares 1999-06-16 15:55:47 Re: [SQL] date