UPDATE with ambigous table name

When doing an UPDATE and there are two occurrances of the table to update, then use the alias as table name. Example

update alias1       -- NOT the table name!
set foo = 'bar'
from table_foobar alias1
inner join table_foobar alias2 on alias2.foo = alias1.bar

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.