From: | "ARP" <arnaud(dot)mlist1(at)free(dot)fr> |
---|---|
To: | "ARP" <arnaud(dot)mlist1(at)free(dot)fr>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Bug or syntax error in my update query with a FROM statement ? |
Date: | 2002-04-24 13:47:16 |
Message-ID: | 030301c1eb96$8d9a3580$0100a8c0@arp.homelinux.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thanks for your reply.
I would tend to agree with you but why doesn't it update ANY row when count() equals zero then, and ALL rows only when the count is not zero ? I would agree with you if ALL rows were updated in any case or did I miss something ?
Arnaud
>The first query SHOULD update all rows, because there is NO restriction
>on the utilisateur table - a.login <> '*' is NOT the same as
>utilisateur.login <> '*' - the former qualifies the FROM clause, and the
>latter applies to the UPDATE itself.
>"Dima Tkach" <dmitry(at)openratings(dot)com> a écrit dans le message de news: 3CC6A7AF(dot)3070801(at)openratings(dot)com(dot)(dot)(dot)
>> Here's the "wrong" query :
>> update utilisateur set login='*', password='*' from utilisateur a, ancien b where a.util_id=b.util_id and b.anc_deces is not null and >(a.login<>'*' or a.password<>'*');
>>
>> Here's the "correct" one :
>> update utilisateur set login='*', password='*' from ancien b where utilisateur.util_id=b.util_id and b.anc_deces is not null and >(utilisateur.login<>'*' or utilisateur.password<>'*');
>>
>> Both queries work the same when there's nothing to update, (i.e. select count(*) from utilisateur a, ancien b where >a.util_id=b.util_id and b.anc_deces is not null and (a.login<>'*' or a.password<>'*') returns 0).
>> But the first one ("wrong") updates ALL rows of table 'utilisateur' when the above count() is not 0, where the second one >("correct") updates only the rows needed.
>>
>> What's wrong with the first query : me or the parser ? I guess the problem comes from the fact that table 'utilisateur' appears twice and is aliased which may confuse the parser in the "wrong" query...
>>
From | Date | Subject | |
---|---|---|---|
Next Message | Alban Médici | 2002-04-24 13:49:18 | Plpgsql get record value without colunm name ??? |
Previous Message | Alban Médici | 2002-04-24 13:45:38 | Plpgsql get record value without colunm name ??? |