Re: update from another table - Mailing list pgsql-sql

From Josh Berkus
Subject Re: update from another table
Date
Msg-id web-70963@davinci.ethosmedia.com
Whole thread Raw
In response to update from another table  ("ivan" <IVANCCC@terra.es>)
List pgsql-sql
Ivan,

> i would like to know how can i update a table with columns from
> another
> table and adding a new column with a secuence,

You cannot update a table and add a new column at with one statement.
Updating a table is Data Manipulation Language (DML) and adding a column
is Data Definition Language (DDL) and the two may not be combined.

For the update statement:

> update table
> set column = (select column from table2), ......, set
> column=secuence..
> 
> is it right?????

Nope.  Try

UPDATE table1 SET columnC = table2.columnB
FROM table2
WHERE table2.columnA = table1.columnA

-Josh Berkus


______AGLIO DATABASE SOLUTIONS___________________________                                      Josh Berkus Complete
informationtechnology      josh@agliodbs.com  and data management solutions       (415) 565-7293 for law firms, small
businesses       fax 621-2533   and non-profit organizations.      San Francisco
 


pgsql-sql by date:

Previous
From: Roberto Mello
Date:
Subject: Re: PL/PGSQL
Next
From: Philip Hallstrom
Date:
Subject: Re: Bit Mapping operation