Home > Archive > PostgreSQL SQL > November 2006 > SQL - update table problem...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author SQL - update table problem...
Marko Rihtar

2006-11-13, 5:30 am

Hi,

first i'm sorry if this message appears twice. first time didn't get through
because i wasn't registered.

i'm trying to do update on multiple tables but don't know how.
is something like this posible with postgresql?

update table1
join table2 on (table1.id=table2.t1)
join table3 on (table2.id=table3.t2)
set table1.name='test', table2.sum=table1.x+table2.y,
table3.cell='123456789'
where table1.id=6

i know that this syntax is not supported with postgres but i tried to
rewrite the code using this synopsis:

UPDATE [ ONLY ] table SET column = { expression | DEFAULT } [, ...]
[ FROM fromlist ]
[ WHERE condition ]

i failed again.

thanks for help

____________________
____________________
____________________
_____
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/...1ave/direct/01/


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Bruno Wolff III

2006-11-15, 5:19 am

On Mon, Nov 13, 2006 at 11:36:05 +0100,
Marko Rihtar <riki_fox@hotmail.com> wrote:
>
> i'm trying to do update on multiple tables but don't know how.
> is something like this posible with postgresql?


I believe you need to use multiple update statements to do this. Each
update can only update one table. You can join with other tables to
select which rows to update, but that doesn't let you update more than
one table at once.

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com