From: | paallen(at)attglobal(dot)net |
---|---|
To: | pgsql-sql(at)postgresql(dot)org, |
Subject: | Update Field with function/data from other tables? |
Date: | 2007-04-06 16:57:06 |
Message-ID: | 20070406170214.CCB0C9FB53B@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | George Pavlov | 2007-04-06 22:09:21 | dropping a schema and cross-schema dependencies |
Previous Message | Shavonne Marietta Wijesinghe | 2007-04-06 07:10:00 | Re: Insert only if not found |