From: | Jason Tan Boon Teck <tanboonteck(at)gmail(dot)com> |
---|---|
To: | Andreas <maps(dot)on(at)gmx(dot)net> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Update a table from another table |
Date: | 2010-11-12 10:00:26 |
Message-ID: | AANLkTimQudxc6c=5ZtWMYVgROJ2gqS=4FuM2sBsDn9H8@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hi Andreas
Thank you for your reply. I've understood and got it working now.
Warm regards,
Jason Tan Boon Teck
On Thu, Nov 11, 2010 at 13:15, Andreas <maps(dot)on(at)gmx(dot)net> wrote:
> Am 11.11.2010 05:25, schrieb Jason Tan Boon Teck:
>>
>> 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.
>
> There is no wildcard mentioned besides the one in the last line, but this
> refers to the columns you might want to get returned after the update.
>
> In case you want to replace the whole contents of records you may try to
> delete the records in tableA and then reinsert them out of your tableB.
> Though this wont work if some other tables have foreign keys of tableA.
>
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice
>
--
Jason Tan Boon Teck
From | Date | Subject | |
---|---|---|---|
Next Message | Vaduvoiu Tiberiu | 2010-11-12 15:39:18 | returning clause on triggers |
Previous Message | LazyTrek | 2010-11-12 06:31:36 | Re: CSVLOG fields |