update with subquery - unexpected results

From: "Niederland" <niederland(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: update with subquery - unexpected results
Date: 2006-02-05 03:47:31
Message-ID: 1139111251.062871.13840@z14g2000cwz.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am using postgres 8.1.2 on a windows computer.
My postgres.config has:
add_missing_from = off

In the following example, the first update sets value for v1 in table
t1 to 4 for all rows.
Just for my sanity, I checked the null condition in the second update,
and this
does not update any of the rows, am I missing something?

create table t1 (v1 integer);
create table t2 (v2 integer);

insert into t1 (v1) values (1);
insert into t1 (v1) values (2);

insert into t2 (v2) values (3);

update t1 set v1=4 where v1 IN (select v1 from t2);

update t1 set v1=4 where v1 IN (select NULLIF(1,1) from t2);

Thanks,
Roger

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Sydney-Smith 2006-02-05 08:27:57 Re: Automating backup
Previous Message Doug McNaught 2006-02-05 02:58:16 Re: plpgsql direct from C?