Update a table from another table

From: Jason Tan Boon Teck <tanboonteck(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Update a table from another table
Date: 2010-11-11 04:25:05
Message-ID: AANLkTik5yLqzacXgwtki5z3fTeacMZ2cROkkzAe3yEpi@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

I am trying to update tableA with records from tableB, in a single SQL
statement, along the lines of

INSERT INTO tablea SELECT * FROM tableb;

but doing UPDATE instead. The manual says

UPDATE [ ONLY ] table [ [ AS ] alias ]
SET { column = { expression | DEFAULT } |
( column [, ...] ) = ( { expression | DEFAULT } [, ...] ) } [, ...]
[ FROM from_list ]
[ WHERE condition | WHERE CURRENT OF cursor_name ]
[ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]

I am having trouble defining the SET part of the statement. The table
has many columns. Is there a wild card or something.

Thanks in advance.

--
Jason Tan Boon Teck

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Andreas 2010-11-11 05:15:57 Re: Update a table from another table
Previous Message Joshua Tolley 2010-11-10 16:52:06 Re: PgFouine