pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
update from another table
3+ messages / 3 participants
[nested] [flat]

* update from another table
@ 2001-06-08 10:03  ivan <IVANCCC@terra.es>
  0 siblings, 2 replies; 3+ messages in thread

From: ivan @ 2001-06-08 10:03 UTC (permalink / raw)
  To: pgsql-sql

dear sir,

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

i have try

update table
set column = (select column from table2), ......, set column=secuence..

is it right?????

thanks

ivan






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: update from another table
@ 2001-06-11 20:37  JWR <readlist@zdnetonebox.com>
  parent: ivan <IVANCCC@terra.es>
  1 sibling, 0 replies; 3+ messages in thread

From: JWR @ 2001-06-11 20:37 UTC (permalink / raw)
  To: pgsql-sql

That doesn't tend to work in any SQL database I've ever used, though I'm
told Informix can do something similiar.

You need to insert the data into a temp table then delete the rows in the
base table, then insert back from the temp table.  Yeah it is a pain.

John


"ivan" <IVANCCC@terra.es> wrote in message
news:9fq8eq$1cpd$1@news.tht.net...
> dear sir,
>
> i would like to know how can i update a table with columns from another
> table and adding a new column with a secuence,
>
> i have try
>
> update table
> set column = (select column from table2), ......, set column=secuence..
>
> is it right?????
>
> thanks
>
> ivan
>
>
>





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: update from another table
@ 2001-06-12 20:03  Josh Berkus <josh@agliodbs.com>
  parent: ivan <IVANCCC@terra.es>
  1 sibling, 0 replies; 3+ messages in thread

From: Josh Berkus @ 2001-06-12 20:03 UTC (permalink / raw)
  To: ivan <IVANCCC@terra.es>; 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 information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2001-06-12 20:03 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-06-08 10:03 update from another table ivan <IVANCCC@terra.es>
2001-06-11 20:37 ` JWR <readlist@zdnetonebox.com>
2001-06-12 20:03 ` Josh Berkus <josh@agliodbs.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox