Re: Update FROM clause?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Booth, Robert" <Robert_Booth(at)intuit(dot)com>
Cc: "PostgreSQL General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Update FROM clause?
Date: 2002-11-01 20:18:59
Message-ID: 1197.1036181939@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Booth, Robert" <Robert_Booth(at)intuit(dot)com> writes:
> SELECT count(*)
> FROM (allforms LEFT OUTER JOIN aanda ON allforms.file__no =
> aanda.file__no)
> INNER JOIN formsin ON allforms.file__no = formsin.file__no
> WHERE ... Omitted ...

> The Postgres UPDATE Query:
> UPDATE allforms
> SET status = 'Okay to Edit'
> FROM formsin LEFT OUTER JOIN aanda ON formsin.file__no = aanda.file__no
> WHERE allforms.file__no = formsin.file__no
> AND ... Omitted, matches the Access Query ...

Those are not the same thing at all. Your UPDATE is more like

SELECT ...
FROM allforms,
(formsin LEFT OUTER JOIN aanda ON formsin.file__no = aanda.file__no)
WHERE allforms.file__no = formsin.file__no
AND ... Omitted, matches the Access Query ...

which is reversing the order of the inner and outer join steps.
Depending on your data this might yield quite a different result.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2002-11-01 20:22:43 Re: [Q] Sequences, last_value and inserts
Previous Message Bruno Wolff III 2002-11-01 20:02:43 Re: [Q] Sequences, last_value and inserts