Josh Berkus <[EMAIL PROTECTED]> 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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

Reply via email to