Re: SubQuery

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: cnliou(at)eurosport(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: SubQuery
Date: 2001-10-04 01:24:03
Message-ID: Pine.BSF.4.21.0110031818200.53481-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Thu, 4 Oct 2001 cnliou(at)eurosport(dot)com wrote:

> What mistake have I made?
>
> database1=# UPDATE mytable SET
> NextNumber=NextNumber+1
> database1-# WHERE id='ID1' AND EffectiveDate=
> database1-# (SELECT MAX(s2.EffectiveDate) FROM
> mytable s2
> database1(# WHERE s2.id=id AND
> s2.EffectiveDate<=CURRENT_DATE);
> UPDATE 0

I think you may need to disambiguate the s2.id=id
in the subquery to s2.id=mytable.id since both
have ids and it's probably assuming that means
s2.id=s2.id.
After changing that I get an UPDATE 1.

In response to

  • SubQuery at 2001-10-04 01:06:04 from cnliou

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 2001-10-04 01:59:44 Re: EXISTS Keyword
Previous Message cnliou 2001-10-04 01:18:53 EXISTS Keyword