From: paallen@attglobal.net
To: pgsql-sql@postgresql.org
Subject: Update Field with function/data from other tables?
Date: Fri, 06 Apr 2007 16:57:06 +0000
Message-ID: <20070406170214.CCB0C9FB53B@postgresql.org> (raw)
Hi all,
I want to update the values of a column with the
result of a function that requires information
from another table. Specifically it needs a
minium and maximum value from another table.
How do I perform the update query?
Below is my attempt but it doesn't work. The
"bhlineid" is my primary key and foreign key in
the 2 tables
UPDATE geo_obs.bhline SET bhline_geom =
CalcBH3dLineMC (minmax.bhlineid,
minmax.srid_original, minmax.from_m, minmax.to_m,
'geo_obs.bhline_surv', 'bhlineid', 'dist_m',
'azim', 'v_inclin',
'bhline_surv_geom', 5.0)
FROM
(SELECT i.bhlineid AS bhlineid, min(i.from_m) AS
from_m,
max(i.to_m) AS to_m, max(c.srid_original) AS
srid_original
FROM geo_obs.bhline_int AS i, geo_obs.bhline AS c
WHERE c.bhlineid=i.bhlineid
GROUP BY i.bhlineid) AS minmax
WHERE geo_obs.bhline.bhlineid = minmax.bhlineid ;
Thanks for any help.
Phillip Allen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: paallen@attglobal.net
Subject: Re: Update Field with function/data from other tables?
In-Reply-To: <20070406170214.CCB0C9FB53B@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox