X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7D7EA329E58 for ; Sat, 11 Sep 2004 07:17:12 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06072-05 for ; Sat, 11 Sep 2004 06:17:06 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1163C329E51 for ; Sat, 11 Sep 2004 07:17:06 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i8B6H3OA007575; Sat, 11 Sep 2004 02:17:03 -0400 (EDT) To: Collin Peters Cc: pgsql-sql@postgresql.org Subject: Re: Using UPDATE FROM In-reply-to: References: Comments: In-reply-to Collin Peters message dated "Thu, 09 Sep 2004 19:54:05 +0000" Date: Sat, 11 Sep 2004 02:17:03 -0400 Message-ID: <7574.1094883423@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/84 X-Sequence-Number: 18930 Collin Peters writes: > Here is the UPDATE statement: > UPDATE programactivitysets SET repsvalue = reps_actual > FROM workouts w, workoutactivities wa, workoutactivitysets was, > programactivities pa, programactivitysets pas > WHERE wa.workout_id = w.workout_id > AND was.workoutactivity_id = wa.workoutactivity_id > AND pa.programactivity_id = wa.programactivity_id > AND pas.programactivity_id = pa.programactivity_id > AND pas.set = was.set > AND w.workout_id = 6036; I think you're imagining that "programactivitysets pas" in the FROM clause is the same as the target table "programactivitysets". It's not, at least not in Postgres, though I've heard tell that MS SQL interprets it that way for some unfathomable reason. Drop the FROM entry and s/pas/programactivitysets/ in the WHERE clause, and I think you'll be good to go ... regards, tom lane