Re: [GENERAL] Postgres update with self join

2004-08-15 Thread Igor Kryltsov
Thank you very much. This works: UPDATE test SET code=T2.code FROM test T2 WHERE test.code=0 AND test.master=T2.name; Igor ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [GENERAL] Postgres update with self join

2004-08-10 Thread Franco Bruno Borghesi
This is the way you do it in postgreSQL: UPDATE    test SET    code=T2.code FROM    test T2 WHERE    test.code=0 AND    test.master=T2.name; you need to specify the join condition in the WHERE clause. On Tue, 2004-08-10 at 00:34, Igor Kryltsov wrote: Hi, If you can help me to correct my

Re: [GENERAL] Postgres update with self join

2004-08-10 Thread Tom Lane
"Igor Kryltsov" <[EMAIL PROTECTED]> writes: > Now I need to replace "0" values in "code" column by corresponding "code" > values by following link between "master" field in a record where code=0 and > "name" field where it is not. > This update works in MSSQL but in Postgres it replaces code value

Re: [GENERAL] Postgres update with self join

2004-08-10 Thread Stephan Szabo
On Tue, 10 Aug 2004, Igor Kryltsov wrote: > Table looks like: > > select * from test; > name | code | master > --+---+ > ABC | 15074 | > ABC1 | 0 | ABC > ABC2 | 0 | ABC > EKL | 15075 | > EKL1 | 0 | EKL > (5 rows) > > > Now I need to replace "0" values in "code