pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Collin Peters <cpeters@mcrt.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: Using UPDATE FROM
Date: Sat, 11 Sep 2004 02:17:03 -0400
Message-ID: <7574.1094883423@sss.pgh.pa.us> (raw)
In-Reply-To: <xx20d.117588$A8.5766@edtnps89>
References: <xx20d.117588$A8.5766@edtnps89>

Collin Peters <cpeters@mcrt.ca> 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



view thread (2+ messages)

Message-ID: <7574.1094883423@sss.pgh.pa.us>
Permalink:  ../7574.1094883423@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7574.1094883423@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, cpeters@mcrt.ca
  Subject: Re: Using UPDATE FROM
  In-Reply-To: <7574.1094883423@sss.pgh.pa.us>

* 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