Re: Subselects - recursion problem

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Philip Rhoades <phil(at)chu(dot)com(dot)au>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Subselects - recursion problem
Date: 2005-05-30 09:50:27
Message-ID: 20050530095023.GB28961@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, May 30, 2005 at 07:33:04PM +1000, Philip Rhoades wrote:
> People,
>
> The following script works (I have confirmed it by doing two separate
> views and doing a select on them) - but I don't understand why there
> isn't a recursion problem with c1.policy and c2.policy - is there some
> sort of trick happening?

"recursion problem" ? It's called a correlated subquery. SQL is
declarative, you state what you want and the database figures out how
to get the answer for you. I think you need to go and read up on the
basics of SQL.

If you want to see *how* the database is working out the answer, use
explain and it'll display the query plan.

Hope this helps,

--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Philip Rhoades 2005-05-30 10:32:15 Re: Subselects - recursion problem
Previous Message Peter Eisentraut 2005-05-30 09:42:57 Re: Subselects - recursion problem