From: Tom Lane <tgl@sss.pgh.pa.us>
To: Gary Stainburn <gary.stainburn@ringways.co.uk>
Cc: pgsql-sql@postgresql.org
Subject: Re: subselect prob in view
Date: Tue, 22 Jun 2004 09:56:27 -0400
Message-ID: <17154.1087912587@sss.pgh.pa.us> (raw)
In-Reply-To: <200406221034.10689.gary.stainburn@ringways.co.uk>
References: <200406211110.39940.gary.stainburn@ringways.co.uk>
<1916.1087827583@sss.pgh.pa.us>
<200406211611.42573.gary.stainburn@ringways.co.uk>
<200406221034.10689.gary.stainburn@ringways.co.uk>
Gary Stainburn <gary.stainburn@ringways.co.uk> writes:
> The two selects work seperately, but I'm still getting the
> syntax for the combined quiery wrong.
What you've got here reduces to
select co.co_r_id, co.count as com_count, cor.count as com_unseen
from
(select ...) co,
(select ...) cor on co.co_r_id = cor.co_r_id;
which is invalid because "ON something" must be associated with JOIN.
You could write either of
select co.co_r_id, co.count as com_count, cor.count as com_unseen
from
(select ...) co join
(select ...) cor on co.co_r_id = cor.co_r_id;
select co.co_r_id, co.count as com_count, cor.count as com_unseen
from
(select ...) co,
(select ...) cor
where co.co_r_id = cor.co_r_id;
but you can't mix-and-match.
With an inner join there isn't any semantic difference between ON and
WHERE, so it's a matter of taste which to use. But with outer joins
there's a big difference.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, gary.stainburn@ringways.co.uk
Subject: Re: subselect prob in view
In-Reply-To: <17154.1087912587@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox