From: | Jan Wieck <janwieck(at)yahoo(dot)com> |
---|---|
To: | Richard Huxton <dev(at)archonet(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: UPDATE ... FROM vs standard SQL |
Date: | 2002-06-07 14:20:05 |
Message-ID: | 200206071420.g57EK5B27878@saturn.janwieck.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Richard Huxton wrote:
> I've been happily using statements like
> UPDATE a SET flag=1 FROM b WHERE a.id=b.id AND b.foo='x';
>
> While PG's FROM extension makes life simple, I can't believe there's not a way
> to do an update on a join using standard SQL. The two options I can think of
> are:
>
> 1. using a sub-select
> UPDATE a SET flag=1 WHERE a.id IN (SELECT id FROM b WHERE b.foo='X');
> Which is fine, but no good for mysql, hits PG's speed issue with IN and a bit
> clumsy for more complicated examples.
>
> 2. building an updatable view.
If your goal is to gain better portability for your app, go
with the subselect. Updatable views, especially if they do
joins, are far less supported (if at all).
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #
From | Date | Subject | |
---|---|---|---|
Next Message | Zeugswetter Andreas SB SD | 2002-06-07 14:23:42 | Re: [HACKERS] PostgreSQL on AIX |
Previous Message | Joseph Syjuco | 2002-06-07 14:08:50 | Re: arrays as pgsql function parameters |