Re: UPDATE ... FROM vs standard SQL - Mailing list pgsql-sql

From Jan Wieck
Subject Re: UPDATE ... FROM vs standard SQL
Date
Msg-id 200206071420.g57EK5B27878@saturn.janwieck.net
Whole thread Raw
In response to UPDATE ... FROM vs standard SQL  (Richard Huxton <dev@archonet.com>)
List 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@Yahoo.com #




pgsql-sql by date:

Previous
From: "Ian Cass"
Date:
Subject: select failure
Next
From: "Josh Berkus"
Date:
Subject: Re: UPDATE ... FROM vs standard SQL