table alias for update

Started by Nonameabout 14 years ago2 messagesgeneral
Jump to latest
#1Noname
hamann.w@t-online.de

is there a way to use a table alias for the target table in an UPDATE query?
I would like to avoid spelling out things like that in psql:

update myverylongtablename set col1 = r.col1repl from repltable r
where myverylongtablename.id = r.id and myverylongtablename.col2 > 0

Regards
Wolfgang Hamann

#2Bosco Rama
postgres@boscorama.com
In reply to: Noname (#1)
Re: table alias for update

hamann.w@t-online.de wrote:

is there a way to use a table alias for the target table in an UPDATE query?
I would like to avoid spelling out things like that in psql:

update myverylongtablename set col1 = r.col1repl from repltable r
where myverylongtablename.id = r.id and myverylongtablename.col2 > 0

update myverylongtablename as xyz
set col1 = ...
where xyz.id = ...;

The 'as' is optional ... though easier to read IMO.

HTH

Bosco.