pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jan Wieck <janwieck@yahoo.com>
To: Richard Huxton <dev@archonet.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: UPDATE ... FROM vs standard SQL
Date: Fri, 7 Jun 2002 10:20:05 -0400 (EDT)
Message-ID: <200206071420.g57EK5B27878@saturn.janwieck.net> (raw)
In-Reply-To: <200206071133.23179.dev@archonet.com>

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 #





view thread (6+ messages)  latest in thread

Message-ID: <200206071420.g57EK5B27878@saturn.janwieck.net>
Permalink:  ../200206071420.g57EK5B27878@saturn.janwieck.net/
Also on:    postgresql.org/message-id/200206071420.g57EK5B27878@saturn.janwieck.net

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: janwieck@yahoo.com, dev@archonet.com
  Subject: Re: UPDATE ... FROM vs standard SQL
  In-Reply-To: <200206071420.g57EK5B27878@saturn.janwieck.net>
  References: <200206071133.23179.dev@archonet.com> <200206071420.g57EK5B27878@saturn.janwieck.net>

* 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