Re: Bug #938: Wrong UPDATE if exist INNER JOIN and alias for table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: tserge(at)dms(dot)omskcity(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug #938: Wrong UPDATE if exist INNER JOIN and alias for table
Date: 2003-04-08 14:09:23
Message-ID: 26536.1049810963@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

pgsql-bugs(at)postgresql(dot)org writes:
> UPDATE test1 SET value = 10 FROM test1 t1 INNER JOIN test2 ON t1.extid=test2.extid WHERE t1.id=1;

> This expression update all record i table "test1".

Yup, that's what it should do. "FROM test1 t1" adds an additional table
reference that's unconnected to the update target table. You should
have written

UPDATE test1 SET value = 10
FROM test2 WHERE test1.extid=test2.extid AND test1.id=1;

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Stephan Szabo 2003-04-08 14:48:16 Re: Bug #938: Wrong UPDATE if exist INNER JOIN and alias
Previous Message pgsql-bugs 2003-04-08 09:09:05 Bug #938: Wrong UPDATE if exist INNER JOIN and alias for table