X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B680FD1B9E5 for ; Mon, 23 Feb 2004 12:10:05 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 69892-01 for ; Mon, 23 Feb 2004 08:10:00 -0400 (AST) Received: from mailhost.realprogrammers.com (mythix.realprogrammers.com [195.82.114.220]) by svr1.postgresql.org (Postfix) with ESMTP id E1E24D1BA8E for ; Mon, 23 Feb 2004 08:09:54 -0400 (AST) Received: from paulm auth id=paulm auth sender=paulm@realprogrammers.com by mythix.realprogrammers.com with local (Exim 4.05-VA-mm1 #1 (Debian)) id 1AvEvR-0004tL-00 for pgsql-docs@postgresql.org; Mon, 23 Feb 2004 12:11:05 +0000 Date: Mon, 23 Feb 2004 12:11:05 +0000 From: Paul Makepeace To: PostgreSQL Docs Subject: UPDATE FROM syntax Message-ID: <20040223121105.GO8784@mythix.realprogrammers.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.5.1+cvs20040105i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/34 X-Sequence-Number: 2289 Hi, is there any documentation for Pg's UPDATE FROM (apparently non-standard) syntax? It is mentioned briefly in \h update and not at all in http://www.postgresql.org/docs/7.3/static/dml-update.html or http://www.postgresql.org/docs/7.3/static/queries-table-expressions.html (directly). [moving a bit OT for docs?] I solved my own problem but was still curious since it's non-standard if there's a "more standard" way of updating a table from another query. ALTER TABLE components ADD COLUMN default_body TEXT; UPDATE components SET default_body = bb.body FROM (SELECT b.body, cpb.component_id FROM componentspagesbodies cpb NATURAL JOIN bodies b WHERE cpb.page_id IS NULL) AS bb WHERE bb.component_id = components.component_id; (Incidently, I tried UPDATE components c SET ... c.component_id but the parser wasn't happy with it.) Paul (PS and now at least one working UPDATE FROM example is online ;-) -- Paul Makepeace ................................ http://paulm.com/ecademy "What is it i am yapping about? Three things: location, location, location." -- http://paulm.com/toys/surrealism/