From: | nolan(at)celery(dot)tssi(dot)com |
---|---|
To: | pgman(at)candle(dot)pha(dot)pa(dot)us (Bruce Momjian) |
Cc: | nagy(at)ecircle-ag(dot)com (Csaba Nagy), tgl(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane), jim(at)nasby(dot)net, pgsql-general(at)postgresql(dot)org (Postgres general mailing list) |
Subject: | Re: table alias on update, another update question |
Date: | 2003-06-24 02:31:01 |
Message-ID: | 20030624023101.1679.qmail@celery.tssi.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> * Allow UPDATE, DELETE to handle table aliases for self-joins [delete]
Thanks. I need to set up a system for 7.4, in the hopes that eventually
I can become a contributor rather than just a consumer.
I've got another SQL-related question about UPDATE.
I need to update several columns in table1 with either the minimum or
maximum value of a corresponding column in a matching set of rows in
table2. I'd like to be able to do it in a single query.
The following doesn't work, it updates just one row.
UPDATE table1
set t1_col1 = max(t2_col1),
t1_col2 = min(t2_col2)
from table2
where t1_key = t2_key
I don't seem to be able to use a group clause.
Is there a way to write this query?
--
Mike Nolan
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2003-06-24 02:54:54 | Re: PlPython |
Previous Message | Bruce Momjian | 2003-06-24 01:54:41 | Re: Why can't you define a table alias on an update? |