pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedNo JOINs in UPDATE ... FROM?
2+ messages / 2 participants
[nested] [flat]
* No JOINs in UPDATE ... FROM?
@ 2001-04-26 17:42 Josh Berkus <josh@agliodbs.com>
0 siblings, 1 reply; 2+ messages in thread
From: Josh Berkus @ 2001-04-26 17:42 UTC (permalink / raw)
To: pgsql-sql
Folks,
In 7.1 RC2, I've been trying to use the following JOIN syntax:
UPDATE assignments SET status = -1
FROM assignments JOIN orders ON assignments.order_usq = orders.usq
WHERE orders.status = -1;
However, I get an error of "Relation assignments referenced twice in
query."
Now, I can (and have) re-phrase the query so that PostgreSQL will
accept it. However, I was under the impression that the above was
standard SQL92. Am I mistaken? Or is this form something that just
hasn't been implemented yet?
-Josh
--
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: No JOINs in UPDATE ... FROM?
@ 2001-04-26 22:15 Tom Lane <tgl@sss.pgh.pa.us>
parent: Josh Berkus <josh@agliodbs.com>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2001-04-26 22:15 UTC (permalink / raw)
To: josh@agliodbs.com; +Cc: pgsql-sql
Josh Berkus <josh@agliodbs.com> writes:
> UPDATE assignments SET status = -1
> FROM assignments JOIN orders ON assignments.order_usq = orders.usq
> WHERE orders.status = -1;
> However, I get an error of "Relation assignments referenced twice in
> query."
> Now, I can (and have) re-phrase the query so that PostgreSQL will
> accept it. However, I was under the impression that the above was
> standard SQL92. Am I mistaken?
You are mistaken. SQL92 and SQL99 don't allow a FROM clause in UPDATE
at all: they say it's just
<update statement: searched> ::=
UPDATE <target table>
SET <set clause list>
[ WHERE <search condition> ]
Postgres allows the clause, but treats it as supplying *additional*
table references besides the target table reference. Thus the error.
In other words: you can JOIN, but not against the target table.
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-04-26 22:15 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-04-26 17:42 No JOINs in UPDATE ... FROM? Josh Berkus <josh@agliodbs.com>
2001-04-26 22:15 ` Tom Lane <tgl@sss.pgh.pa.us>
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